Frame
class and extended Stage
which creates all required Scene
and RootPane
objects under the hood. It's a convenient class if additional stages/windows (non-primary) are required. The window decoration is
non-native by default.The static method #setNativeDecorationEnabled(boolean)
can be used to enable native decoration for
all frames - the method has to be called before any Frame
is instantiated. The class is similar to Swing's JFrame
.
// conventional way to create a new window
Stage stage = new Stage();
Scene scene = new Scene(new RootPane(stage, createContentPane()), 800, 600);
stage.setScene(scene);
stage.setTitle("MyWindow");
...
stage.show
// convenient method, creates a child window - primaryStage is the owner
Frame f = new Frame(primaryStage, "MyFrame", createContentPane(), 400, 300);
...
f.show();