I want to find a VBox node in a scene loaded with FXMLoader
thanks to Node#lookup()
but I get the following exception :
java.lang.ClassCastException: com.sun.javafx.scene.control.skin.SplitPaneSkin$Content cannot be cast to javafx.scene.layout.VBox
The code :
public class Main extends Application { public static void main(String[] args) { Application.launch(Main.class, (java.lang.String[]) null); } @Override public void start(Stage stage) throws Exception { AnchorPane page = (AnchorPane) FXMLLoader.load(Main.class.getResource("test.fxml")); Scene scene = new Scene(page); stage.setScene(scene); stage.show(); VBox myvbox = (VBox) page.lookup("#myvbox"); myvbox.getChildren().add(new Button("Hello world !!!")); } }
The fxml file:
I would like to know :
1. Why lookup method return a SplitPaneSkin$Content
and not a VBox
?
2. How I can get the VBox
in another manner ?
Thanks in advance