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.
Asked
Active
Viewed 2,354 times
0
-
1by calling it as soon as the stage commences. – Stultuske Mar 29 '16 at 10:38
1 Answers
4
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"/>

jewelsea
- 150,031
- 14
- 366
- 406
-
-
Good workaround to trigger the button in initialize(). Thank you! – alchemist.gamma Oct 16 '17 at 00:38