Reputation: 1747
I have the following code which sets my parent layout:
public void start(Stage primaryStage) {
try {
Parent root = FXMLLoader.load(getClass().getResource("/view/BaseStructure.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
I want to add another layout to the right
of the parent layout. How can I do this in the main class?
This is what my parent layout .fxml
file looks like:
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Main">
//more code here
<right>
//need my second layout here
</right>
</VBox>
Upvotes: 1
Views: 918
Reputation: 49185
You can use another layout of your choice that wraps two layouts you have:
HBox hbox = new HBox(10);
hbox.getChildren().addAll(getMySecondLayout(), root);
Scene scene = new Scene(hbox);
Alternatively you can redesign all GUI and use other layouts like BorderPane
, AnchorPane
etc.
Upvotes: 1