Installing a class controller for a mesh panel

When working with JavaFX Scene Builder, the following problem occurred ...

Given:

An fxml file containing the description of Anchor Pane (fxml generated from Scene Builder),
An anchor panel does not have a controller class.
This fxml is loaded into a Java application using FXMLLoader.

Need:

After loading the binding panel, set the value to the controller class.
You need to load the same fxml with different handlers.

Question: is it possible, and if so - how to implement it?

+4
source share
1 answer

The FXML download controller class can also be set via Scene Builder. But you want to install it during application download. To do this, you must install the FXMLLoader controller before calling the load () method:

AnchorPane rootPane; MyController controller = new MyController(); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("my.fxml")); fxmlLoader.setRoot(rootPane); fxmlLoader.setController(controller); fxmlLoader.load(); 
+8
source

All Articles