Some JavaFX components for making your life easier.
com.nonacept.javafx.scene.layout.InternalWindow is similar to JInternalWindow from Swing.
It extends Pane and can be added to any Parent, allowing content to be added inside a "window within a window". You can move, resize, and maximize it.
For this example, I will assume you already know a bit of JavaFX and have a Pane ready to be used as a "Desktop":
InternalWindowManager iwm = InternalWindowManager
.create()
.managing(contentPanel);After this the object iwm can be used to manage the creation of InternalWindow.
You can create windows with:
createInternalWindow→ multiple instances allowed.createUniqueInternalWindow→ only one instance; focuses if called again. (Note: the uniqueness is based on the typeClass)
iwm.createUniqueInternalWindow("/example.fxml",
mainStage,
ExampleController.class,
customInitConsumer
);Parameters:
| Parameter | Description |
|---|---|
/example.fxml |
Location of the FXML file |
mainStage |
Main Stage (can be null) |
ExampleController.class |
Your FXML controller implementing InternalWindowContent (also used to manage the uniqueness) |
customInitConsumer |
Custom code to run on initialization |
Note: every parameter passed when creating the InternalWindowManager will be used for all InternalWindow created by it.
InternalWindowInitializer<ExampleController> initializer = (controller, stage, internalWindow) -> {
controller.doSomething(stage);
controller.alsoDoThis(internalWindow);
};
InternalWindowManager iwm = InternalWindowManager
.create()
.managing(contentPanel)
.withInitializer(initializer);The global initializer code, will be executed when creating a InternalWindow.
As you may see the initializer must be a implementation of InternalWindowInitializer with a controller type as parameter.
Note: if you intend to use InternalWindows with multiple types of controllers, define a more generic Controller class to be used here and extend by the actual Controllers, or use a customInitConsumer for every Window, as the InternalWindow creation example.
You can provide an Object that implements ChildListener in order to receive calls when the InternalWindow opens or closes; a InternalWindow.Theme can also be passed:
InternalWindowManager iwm = InternalWindowManager
.create()
.managing(contentPanel)
.withListener(this) // listens to open/close
.defaultTheme(InternalWindow.Theme.NONACEPT); // set themeCurrently available themes: JAVAFX and NONACEPT.
InternalWindowInitializer<ExampleController> initializer = ((controller, stage, internalWindow) -> {
controller.doSomething(stage);
controller.alsoDoThis(internalWindow);
});
InternalWindowManager iwm = InternalWindowManager
.create()
.managing(contentPanel)
.withListener(this)
.withInitializer(initializer)
.defaultTheme(InternalWindow.Theme.NONACEPT);
iwm.createUniqueInternalWindow("/example.fxml", mainStage, ExampleController.class, customInitConsumer);
iwm.createInternalWindow("/example.fxml", mainStage, customInitConsumer);Click the images to enlarge:


