Java Code Examples for javafx.stage.StageStyle#UTILITY

The following examples show how to use javafx.stage.StageStyle#UTILITY . 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: NaviSelectDemo.java    From tornadofx-controls with Apache License 2.0 6 votes vote down vote up
/**
 * Select value example. Implement whatever technique you want to change value of the NaviSelect
 */
private void selectEmail(NaviSelect<Email> navi) {
	Stage dialog = new Stage(StageStyle.UTILITY);
	dialog.setTitle("Choose person");
	ListView<Email> listview = new ListView<>(FXCollections.observableArrayList(
		new Email("[email protected]", "John Doe"),
		new Email("[email protected]", "Jane Doe"),
		new Email("[email protected]", "Some Dude")
	));
	listview.setOnMouseClicked(event -> {
		Email item = listview.getSelectionModel().getSelectedItem();
		if (item != null) {
			navi.setValue(item);
			dialog.close();
		}
	});
	dialog.setScene(new Scene(listview));
	dialog.setWidth(navi.getWidth());
	dialog.initModality(Modality.APPLICATION_MODAL);
	dialog.setHeight(100);
	dialog.showAndWait();
}
 
Example 2
Source File: UndecoratorScene.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * UndecoratorScene constructor
 *
 * @param stage The main stage
 * @param stageStyle could be StageStyle.UTILITY or StageStyle.TRANSPARENT
 * @param root your UI to be displayed in the Stage
 * @param stageDecorationFxml Your own Stage decoration or null to use the
 * built-in one
 */
public UndecoratorScene(Stage stage, StageStyle stageStyle, Region root, String stageDecorationFxml) {
    super(root);
    myRoot = root;
    /*
     * Fxml
     */
    if (stageDecorationFxml == null) {
        if (stageStyle == StageStyle.UTILITY) {
            stageDecorationFxml = STAGEDECORATION_UTILITY;
        } else {
            stageDecorationFxml = STAGEDECORATION;
        }
    }
    undecorator = new Undecorator(stage, root, stageDecorationFxml, stageStyle);
    super.setRoot(undecorator);

    // Customize it by CSS if needed:
    if (stageStyle == StageStyle.UTILITY) {
        undecorator.getStylesheets().add(STYLESHEET_UTILITY);
    } else {
        undecorator.getStylesheets().add(STYLESHEET);
    }

    // Transparent scene and stage
    if (stage.getStyle() != StageStyle.TRANSPARENT) {
        stage.initStyle(StageStyle.TRANSPARENT);
    }
    super.setFill(Color.TRANSPARENT);

    // Default Accelerators
    undecorator.installAccelerators(this);

    // Forward pref and max size to main stage
    stage.setMinWidth(undecorator.getMinWidth());
    stage.setMinHeight(undecorator.getMinHeight());
    stage.setWidth(undecorator.getPrefWidth());
    stage.setHeight(undecorator.getPrefHeight());
}
 
Example 3
Source File: InfoBox.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
public InfoBox(final Window owner, final String title, final String labelText, 
        final String textAreaText, final boolean editable, final int width, final int height) {
    final VBox pane = new VBox(20);
    pane.setId(StageController.FX_CONNECTOR_BASE_ID + "InfoBox");
    final Scene scene = new Scene(pane, width, height); 

    final Stage stage = new Stage(StageStyle.UTILITY);
    stage.setTitle(title);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initOwner(owner);
    stage.setScene(scene);
    stage.getIcons().add(ScenicViewGui.APP_ICON);

    final Label label = new Label(labelText);
    stage.setWidth(width);
    stage.setHeight(height);
    textArea = new TextArea();
    if (textAreaText != null) {
        textArea.setEditable(editable);
        textArea.setText(textAreaText);
        VBox.setMargin(textArea, new Insets(5, 5, 0, 5));
        VBox.setVgrow(textArea, Priority.ALWAYS);
    }
    final Button close = new Button("Close");
    VBox.setMargin(label, new Insets(5, 5, 0, 5));

    VBox.setMargin(close, new Insets(5, 5, 5, 5));

    pane.setAlignment(Pos.CENTER);

    close.setDefaultButton(true);
    close.setOnAction(new EventHandler<ActionEvent>() {
        @Override public void handle(final ActionEvent arg0) {
            stage.close();
        }
    });
    if (textArea != null) {
        pane.getChildren().addAll(label, textArea, close);
    } else {
        pane.getChildren().addAll(label, close);
    }

    stage.show();
}