All panes tries to layout and to resize its children if possible, and all panes are resized by their parents by respecting their content. Read the javadoc for more information.
All panes (VBox
, StackPane
, FlowPane
, Pane
etc.) are packaged into javafx.scene.layout
package which implies these panes are used for laying out other nodes/controls.
The shapes you are actually tried to obtain are packaged into javafx.scene.shape
package. Use them as, for instance:
red1.getChildren().add(new Rectangle(200, 100, Color.YELLOW));
...
red2.getChildren().add(new Circle(30, Color.BLUE));