if (modal) {
initModality(Modality.WINDOW_MODAL);
}
resizableProperty().addListener(new InvalidationListener() {
@Override public void invalidated(Observable valueModel) {
resizeCorner.setVisible(isResizable());
maxButton.setVisible(isResizable());
if (isResizable()) {
windowBtns.getChildren().add(1, maxButton);
} else {
windowBtns.getChildren().remove(maxButton);
}
}
});
root = new BorderPane();
Scene scene;
if (stageStyle == StageStyle.DECORATED) {
scene = new Scene(root);
// !CHANGE START!
scene.getStylesheets().addAll(DIALOGS_CSS_URL.toExternalForm());
// !CHANGE END!
setScene(scene);
return;
}
// *** The rest is for adding window decorations ***
decoratedRoot = new RootPane() {
@Override protected void layoutChildren() {
super.layoutChildren();
if (resizeCorner != null) {
resizeCorner.relocate(getWidth() - 20, getHeight() - 20);
}
}
};
decoratedRoot.getChildren().add(root);
scene = new Scene(decoratedRoot);
// !CHANGE START!
String css = (String) AccessController.doPrivileged(new PrivilegedAction() {
@Override public Object run() {
return DIALOGS_CSS_URL.toExternalForm();
}
});
scene.getStylesheets().addAll(css);
// !CHANGE END!
scene.setFill(Color.TRANSPARENT);
setScene(scene);
decoratedRoot.getStyleClass().addAll("dialog", "decorated-root");
focusedProperty().addListener(new InvalidationListener() {
@Override public void invalidated(Observable valueModel) {
decoratedRoot.pseudoClassStateChanged("active");
}
});
ToolBar toolBar = new ToolBar();
toolBar.getStyleClass().add("window-header");
toolBar.setPrefHeight(HEADER_HEIGHT);
toolBar.setMinHeight(HEADER_HEIGHT);
toolBar.setMaxHeight(HEADER_HEIGHT);
// add window dragging
toolBar.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent event) {
mouseDragOffsetX = event.getSceneX();
mouseDragOffsetY = event.getSceneY();
}
});
toolBar.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent event) {
setX(event.getScreenX() - mouseDragOffsetX);
setY(event.getScreenY() - mouseDragOffsetY);
}
});
titleLabel = new Label();
titleLabel.getStyleClass().add("window-title");
titleLabel.setText(getTitle());
titleProperty().addListener(new InvalidationListener() {
@Override public void invalidated(Observable valueModel) {
titleLabel.setText(getTitle());
}
});