We have several JavaFX views created with the help of scenebuilder. Their components get injected in controller classes through the FXMLLoader
, like for example a TreeTableView
. Now I'd like to override a specific method of TreeTableView
, but since it gets initialized by FXMLLoader
, I am not sure how to approach this.
Is there any way to override a method of TreeTableView
injected by FXMLLoader without creating and importing a new control to scenebuilder?
To override a method in SceneBuilder, you need to subclass the target control in Java or some other object oriented language and import your subclass into SceneBuilder.
FXML (on which SceneBuilder is based), is just a declarative system, it doesn't have constructs like subclassing.
Many JavaFX controls have settable event handlers (such as setOnMouseClicked) and are also customizable using CSS. Both of these things can be manipulated in SceneBuilder and FXML. So there is quite a lot of customization you can do without creating a new control or subclass, but sometimes you may want to create custom controls to get the flexibility you desire.