In JavaFX 1.x, where I've used the FX-Script to setup the Scene, I had the bind keyword:
Dynamic/instant resize in JavaFX
How can I have the same behavior in 2.0?
If you want automatic resize, you should do something like this
private BorderPane root;
@Override
public void start(Stage stage) throws Exception
{
root = new BorderPane();
//ROOT SHOULD BE ONE OF THE LAYOUTS : BorderPane, HBox, VBox, StackPane,
//GridPane, FlowPane
scene = new Scene(root, 500, 500);
stage.setScene(scene);
stage.show();
root.setCenter(new Label("sample label"));
}
I have tried only with BorderPane and it works. Also if you want to create custom component, your class should extend one of layouts. Automatic resize won't work if your component extends Pane or Group
I think this will help to you.
Best regards Sandro