Reputation: 89
I have a scene called homepage.fxml in my application. It has a Linechart in it and I created a button to refresh the chart (that's when the data is displayed). What I want is for the data to be displayed in the chart once the stage commences. I'm guessing I need to call the method (refreshPressed()) when the app starts but I'm a novice programmer so please help me out. I also looked at this: link to something similar but it's not helping.
Upvotes: 0
Views: 2568
Reputation: 159341
In the initialize()
method of the controller for your FXML, invoke fire()
on the button.
Code snippet from the controller:
@FXML Button button;
public void initialize() {
button.fire();
}
@FXML
public void refreshPressed() {
// refresh chart.
}
Corresponding snippet from FXML:
<Button fx:id="button" text="Refresh" onAction="#refreshPressed"/>
Upvotes: 4