Java Code Examples for javafx.stage.StageStyle#UNDECORATED

The following examples show how to use javafx.stage.StageStyle#UNDECORATED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrayNotification.java    From JavaFX-Chat with GNU General Public License v3.0 9 votes vote down vote up
private void initStage() {

        stage = new CustomStage(rootNode, StageStyle.UNDECORATED);
        stage.setScene(new Scene(rootNode));
        stage.setAlwaysOnTop(true);
        stage.setLocation(stage.getBottomRight());

        lblClose.setOnMouseClicked(e -> dismiss());
    }
 
Example 2
Source File: NameEditor.java    From OpenLabeler with Apache License 2.0 4 votes vote down vote up
public String showPopup(double screenX, double screenY, Window window) {
    Scene scene = new Scene(this);
    Stage popupStage = new Stage(StageStyle.UNDECORATED);
    String label = text.getText();
    popupStage.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
        switch (event.getCode()) {
            case ESCAPE: {
                text.setText(label); // discard change
                popupStage.close();
                break;
            }
            case ENTER: {
                int index = list.getSelectionModel().getSelectedIndex();
                if (index >= 0) {
                    text.setText(list.getSelectionModel().getSelectedItem());
                }
                if (text.getText().trim().isEmpty()) {
                    text.setText(label);
                }
                popupStage.close();
                break;
            }
            case UP: {
                list.requestFocus();
                break;
            }
            case DOWN: {
                list.requestFocus();
                if (list.getSelectionModel().getSelectedIndex() < 0) {
                    list.getSelectionModel().select(0);
                }
                break;
            }
            // JavaFX bug - ListView#selectionModel#select does not scroll into view
            /*
            case UP: {
                int index = list.getSelectionModel().getSelectedIndex();
                index = index < 0 ? 0 : (index == 0 ? list.getItems().size() - 1 : index - 1);
                list.getSelectionModel().select(index);
                event.consume();
                break;
            }
            case DOWN: {
                int index = list.getSelectionModel().getSelectedIndex();
                index = index < 0 ? 0 : (index == list.getItems().size() - 1 ? 0 : index + 1);
                list.getSelectionModel().select(index);
                event.consume();
                break;
            }
            */
        }
    });
    popupStage.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> {
        if (!isNowFocused) {
            if (text.getText().trim().isEmpty()) {
                text.setText(label);
            }
            popupStage.hide();
        }
    });
    popupStage.initOwner(window);
    popupStage.initModality(Modality.WINDOW_MODAL);
    popupStage.setScene(scene);

    // Show the stage close to the mouse pointer
    popupStage.setX(screenX + 10);
    popupStage.setY(screenY + 10);

    popupStage.showAndWait();
    return text.getText();
}
 
Example 3
Source File: Undecorator.java    From DevToolBox with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Undecorator(Stage stage, Region root) {
    this(stage, root, "stagedecoration.fxml", StageStyle.UNDECORATED);
}
 
Example 4
Source File: DockNode.java    From DockFX with GNU Lesser General Public License v3.0 4 votes vote down vote up
public final boolean isDecorated() {
  return stageStyle != StageStyle.TRANSPARENT && stageStyle != StageStyle.UNDECORATED;
}