Electric Coffee
Electric Coffee

Reputation: 12104

Invoking code when opening window/stage JavaFX

I'm making a piece of software that needs to load data from a settings file, or a de-serialised object of said file when the window opens, is there some sort of "onOpen" method you can override, so you can execute some code when the window is loading? À la the MainWindow method in WPF. The window is made in FXML.

Upvotes: 0

Views: 61

Answers (1)

Roland
Roland

Reputation: 18415

You can add the following to your controller, it is automatically called after the fxml file has been loaded.

@FXML
private void initialize() {
/* insert code here */
}

Upvotes: 2

Related Questions