JavaFX layouts/scenes

+1 Jake Scaife · March 8, 2015

I'm trying to make a program which incorporates multiple different "elements" into the same Stage.
The elements each have their own layouts, which I would like to keep separate, as they are generated in their own classes.

The problem I have found is when I try and join them together onto a single scene.

I'm just wondering if there is a tool similar to a panel in other languages which itself has a layout, but can also be placed inside a layout, so that each of the different elements 'panels' can be generated in their respective classes, and then placed in a layout on the final scene/stage.

This might seem like a dumb question, please let me know if I haven't explained myself properly.


Post a Reply


Oldest  Newest  Rating
+1 Branislav Lazic · March 8, 2015
Pro tip: Use FXML for layout of components. 
Define fx:controller="org.somepackage.MyController" for top pane in FXML file, create MyController class and inject components from FXML via @FXML annotation. It's a good approach to avoid unnecessary verbosity in Java code for layout of your components.
+1 Jake Scaife · March 8, 2015
After spending quite a bit of time playing with my IDE, I found that you can layer 'Panes' on top of each other. (duh :'( )

So, I create multiple different panes in the respective classes (quite a few GridPanes), add them to a Vbox pane and then initialise the scene with that Vbox pane.
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator