root = (Region) fxmlLoader.load();
} catch (Exception ex) {
ex.printStackTrace();
}
final Undecorator undecorator = new Undecorator(stage, root);
// Customize it by CSS if needed:
undecorator.getStylesheets().add("skin/undecorator.css");
// Optional: Enable this node to drag the stage
// By default the root argument of Undecorator is set as draggable
Node node = root.lookup("#draggableNode");
undecorator.setAsStageDraggable(stage, node);
Scene scene = new Scene(undecorator);
// Install default Accelerators in the Scene
undecorator.installAccelerators(scene);
// Enable fade transition
undecorator.setFadeInTransition();
/*
* Fade transition on window closing request
*/
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent we) {
we.consume(); // Do not hide
undecorator.setFadeOutTransition();
}
});
// Transparent scene and stage
scene.setFill(Color.TRANSPARENT);
stage.initStyle(StageStyle.TRANSPARENT);
stage.setScene(scene);
// Feed Charts with fake data for demo
initCharts();
stage.show();
// Set minimum size
stage.setMinWidth(undecorator.getMinWidth());
stage.setMinHeight(undecorator.getMinHeight());
}