Example usage for javafx.stage Modality APPLICATION_MODAL

List of usage examples for javafx.stage Modality APPLICATION_MODAL

Introduction

In this page you can find the example usage for javafx.stage Modality APPLICATION_MODAL.

Prototype

Modality APPLICATION_MODAL

To view the source code for javafx.stage Modality APPLICATION_MODAL.

Click Source Link

Document

Defines a modal window that blocks events from being delivered to any other application window.

Usage

From source file:com.neuronrobotics.bowlerstudio.MainController.java

/**
 * Initializes the controller class./*  w  w w  . j  a  v  a  2  s.  co  m*/
 *
 * @param url
 * @param rb
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    ScriptingEngine.setLoginManager(new IGitHubLoginManager() {

        @Override
        public String[] prompt(String username) {
            if (!loginWindowOpen && controller != null)
                controller.reset();
            loginWindowOpen = true;
            System.err.println("Calling login from BowlerStudio");
            // new RuntimeException().printStackTrace();
            FXMLLoader fxmlLoader = BowlerStudioResourceFactory.getGithubLogin();
            Parent root = fxmlLoader.getRoot();
            if (controller == null) {
                controller = fxmlLoader.getController();
                Platform.runLater(() -> {
                    controller.reset();
                    controller.getUsername().setText(username);
                    Stage stage = new Stage();
                    stage.setTitle("GitHub Login");
                    stage.initModality(Modality.APPLICATION_MODAL);
                    controller.setStage(stage, root);
                    stage.centerOnScreen();
                    stage.show();
                });
            }
            // setContent(root);
            while (!controller.isDone()) {
                ThreadUtil.wait(100);
            }
            String[] creds = controller.getCreds();
            loginWindowOpen = false;
            return creds;
        }
    });

    jfx3dmanager = new BowlerStudio3dEngine();

    setApplication(new BowlerStudioController(jfx3dmanager, this));
    Platform.runLater(() -> {
        editorContainer.getChildren().add(getApplication());
        AnchorPane.setTopAnchor(getApplication(), 0.0);
        AnchorPane.setRightAnchor(getApplication(), 0.0);
        AnchorPane.setLeftAnchor(getApplication(), 0.0);
        AnchorPane.setBottomAnchor(getApplication(), 0.0);

        subScene = jfx3dmanager.getSubScene();
        subScene.setFocusTraversable(false);
        subScene.setOnMouseEntered(mouseEvent -> {
            // System.err.println("3d window requesting focus");
            Scene topScene = BowlerStudio.getScene();
            normalKeyPessHandle = topScene.getOnKeyPressed();
            jfx3dmanager.handleKeyboard(topScene);
        });

        subScene.setOnMouseExited(mouseEvent -> {
            // System.err.println("3d window dropping focus");
            Scene topScene = BowlerStudio.getScene();
            topScene.setOnKeyPressed(normalKeyPessHandle);
        });

        subScene.widthProperty().bind(viewContainer.widthProperty());
        subScene.heightProperty().bind(viewContainer.heightProperty());
    });

    Platform.runLater(() -> {
        jfx3dControls.getChildren().add(jfx3dmanager.getControlsBox());
        viewContainer.getChildren().add(subScene);
    });

    System.out.println("Welcome to BowlerStudio!");
    new Thread() {
        public void run() {
            setName("Load Haar Thread");
            try {
                HaarFactory.getStream(null);
            } catch (Exception ex) {
            }
        }
    }.start();

    // getAddDefaultRightArm().setOnAction(event -> {
    //
    // application.onAddDefaultRightArm(event);
    // });
    // getAddVRCamera().setOnAction(event -> {
    // if(AddVRCamera.isSelected())
    // application.onAddVRCamera(event);
    // });

    FxTimer.runLater(Duration.ofMillis(100), () -> {
        if (ScriptingEngine.getLoginID() != null) {
            setToLoggedIn(ScriptingEngine.getLoginID());
        } else {
            setToLoggedOut();
        }

    });

    ScriptingEngine.addIGithubLoginListener(new IGithubLoginListener() {

        @Override
        public void onLogout(String oldUsername) {
            setToLoggedOut();
        }

        @Override
        public void onLogin(String newUsername) {
            setToLoggedIn(newUsername);

        }
    });

    cmdLine = new CommandLineWidget();

    Platform.runLater(() -> {
        // logView.resize(250, 300);
        // after connection manager set up, add scripting widget
        logViewRef = new TextArea();
        logViewRef.prefWidthProperty().bind(logView.widthProperty().divide(2));
        logViewRef.prefHeightProperty().bind(logView.heightProperty().subtract(40));
        VBox box = new VBox();
        box.getChildren().add(logViewRef);
        box.getChildren().add(cmdLine);
        VBox.setVgrow(logViewRef, Priority.ALWAYS);
        box.prefWidthProperty().bind(logView.widthProperty().subtract(10));

        logView.getChildren().addAll(box);
    });
}

From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java

private void bulkAddImages() {
    if (sortedRows.size() > 0) {
        Stage stage = new Stage();
        BulkAddImagesView view = new BulkAddImagesView(sortedRows);
        stage.setScene(new SceneStyler().createScene(view, SceneStyler.Style.TOPIC_LIST));
        stage.setTitle(Messages.msg("form.bulk_add_something", Messages.msg("form.image")));
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.initOwner(getScene().getWindow());
        stage.showAndWait();//from  w w  w  .j  a  v  a  2  s  .com

        if (view.isOk()) {
            view.getFiles().entrySet().stream().forEach((entry) -> {
                ((RowForCard) sortedRows.get(entry.getKey())).setImageFile(entry.getValue());
            });
            view.getImages().entrySet().stream().forEach((entry) -> {
                ((RowForCard) sortedRows.get(entry.getKey())).setImage(entry.getValue());
            });
        }
    } else {
        Alert alert = new Alert(Alert.AlertType.WARNING);
        alert.setTitle(Messages.msg("alert.error"));
        alert.setHeaderText(Messages.msg("alert.no_words_image"));
        alert.setContentText(Messages.msg("alert.add_words"));
        alert.showAndWait();
    }
}

From source file:eu.over9000.skadi.ui.MainWindow.java

private void setupToolbar(final Stage stage) {

    this.add = GlyphsDude.createIconButton(FontAwesomeIcons.PLUS);
    this.addName = new TextField();
    this.addName.setOnAction(event -> this.add.fire());

    this.add.setOnAction(event -> {
        final String name = this.addName.getText().trim();

        if (name.isEmpty()) {
            return;
        }/*  w  ww .  j  a v a2  s.  c  om*/

        final boolean result = this.channelHandler.addChannel(name, this.sb);

        if (result) {
            this.addName.clear();
        }

    });

    this.imprt = GlyphsDude.createIconButton(FontAwesomeIcons.DOWNLOAD);
    this.imprt.setOnAction(event -> {
        final TextInputDialog dialog = new TextInputDialog();
        dialog.initModality(Modality.APPLICATION_MODAL);
        dialog.initOwner(stage);
        dialog.setTitle("Import followed channels");
        dialog.setHeaderText("Import followed channels from Twitch");
        dialog.setGraphic(null);
        dialog.setContentText("Twitch username:");

        dialog.showAndWait().ifPresent(name -> {
            final ImportFollowedService ifs = new ImportFollowedService(this.channelHandler, name, this.sb);
            ifs.start();
        });
    });

    this.details = GlyphsDude.createIconButton(FontAwesomeIcons.INFO);
    this.details.setDisable(true);
    this.details.setOnAction(event -> {
        this.detailChannel.set(this.table.getSelectionModel().getSelectedItem());
        if (!this.sp.getItems().contains(this.detailPane)) {
            this.sp.getItems().add(this.detailPane);
            this.doDetailSlide(true);
        }
    });
    this.details.setTooltip(new Tooltip("Show channel information"));

    this.remove = GlyphsDude.createIconButton(FontAwesomeIcons.TRASH);
    this.remove.setDisable(true);
    this.remove.setOnAction(event -> {
        final Channel candidate = this.table.getSelectionModel().getSelectedItem();

        final Alert alert = new Alert(AlertType.CONFIRMATION);
        alert.initModality(Modality.APPLICATION_MODAL);
        alert.initOwner(stage);
        alert.setTitle("Delete channel");
        alert.setHeaderText("Delete " + candidate.getName());
        alert.setContentText("Do you really want to delete " + candidate.getName() + "?");

        final Optional<ButtonType> result = alert.showAndWait();
        if (result.get() == ButtonType.OK) {
            this.channelHandler.getChannels().remove(candidate);
            this.sb.setText("Removed channel " + candidate.getName());
        }
    });

    this.refresh = GlyphsDude.createIconButton(FontAwesomeIcons.REFRESH);
    this.refresh.setTooltip(new Tooltip("Refresh all channels"));
    this.refresh.setOnAction(event -> {
        this.refresh.setDisable(true);
        final ForcedChannelUpdateService service = new ForcedChannelUpdateService(this.channelHandler, this.sb,
                this.refresh);
        service.start();
    });

    this.settings = GlyphsDude.createIconButton(FontAwesomeIcons.COG);
    this.settings.setTooltip(new Tooltip("Settings"));
    this.settings.setOnAction(event -> {
        final SettingsDialog dialog = new SettingsDialog();
        dialog.initModality(Modality.APPLICATION_MODAL);
        dialog.initOwner(stage);
        final Optional<StateContainer> result = dialog.showAndWait();
        if (result.isPresent()) {
            this.persistenceHandler.saveState(result.get());
        }
    });

    this.onlineOnly = new ToggleButton("Live", GlyphsDude.createIcon(FontAwesomeIcons.FILTER));
    this.onlineOnly.setSelected(this.currentState.isOnlineFilterActive());

    this.onlineOnly.setOnAction(event -> {
        this.currentState.setOnlineFilterActive(this.onlineOnly.isSelected());
        this.persistenceHandler.saveState(this.currentState);
        this.updateFilterPredicate();
    });
    // TODO re-enable if 8u60 is released
    this.onlineOnly.setDisable(true);

    this.filterText = new TextField();
    this.filterText.textProperty().addListener((obs, oldV, newV) -> this.updateFilterPredicate());
    this.filterText.setTooltip(new Tooltip("Filter channels by name, status and game"));

    // TODO re-enable if 8u60 is released
    this.filterText.setDisable(true);

    this.tb = new ToolBar();
    this.tb.getItems().addAll(this.addName, this.add, this.imprt, new Separator(), this.refresh, this.settings,
            new Separator(), this.onlineOnly, this.filterText, new Separator(), this.details, this.remove);

    this.chatAndStreamButton = new HandlerControlButton(this.chatHandler, this.streamHandler, this.table,
            this.tb, this.sb);

    this.updateFilterPredicate();
}

From source file:com.SignalDiagram.FXMLDocumentController.java

@FXML
private void showAbout(ActionEvent event) {
    Stage stage = new Stage();
    Parent root;// ww  w.j a  v a 2s.  c  om
    try {
        root = FXMLLoader.load(getClass().getResource("FXMLAbout.fxml"));

        stage.setScene(new Scene(root));
        stage.setTitle("About");
        stage.initStyle(StageStyle.UTILITY);
        stage.initModality(Modality.APPLICATION_MODAL);
        // stage.initOwner(((Node) event.getSource()).getScene().getWindow());
        stage.setResizable(false);
        stage.show();

    } catch (IOException ex) {
        Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.danilafe.sbaccountmanager.StarboundServerAccountManager.java

private void createAccount(ListView<String> to_update) {
    Stage createAccountStage = new Stage();
    createAccountStage.initModality(Modality.APPLICATION_MODAL);

    //Set the stage info
    createAccountStage.setTitle("Add Server Account");

    //Create a layout
    GridPane gp = new GridPane();
    gp.setAlignment(Pos.CENTER);/*  w  w  w  . j  a  va 2 s  .c o m*/
    gp.setVgap(10);
    gp.setHgap(10);
    gp.setPadding(new Insets(25, 25, 25, 25));

    //Ads the important things
    Text welcome = new Text("Create Server Account");
    welcome.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20));
    gp.add(welcome, 0, 0, 2, 1);

    Label username = new Label("Username");
    Label password = new Label("Password");
    Label r_password = new Label("Repeat Password");

    TextField usernamefield = new TextField();
    PasswordField passwordfield = new PasswordField();
    PasswordField r_passwordfield = new PasswordField();

    gp.add(username, 0, 1);
    gp.add(password, 0, 2);
    gp.add(r_password, 0, 3);

    gp.add(usernamefield, 1, 1);
    gp.add(passwordfield, 1, 2);
    gp.add(r_passwordfield, 1, 3);

    Text error = new Text("");
    HBox error_box = new HBox(10);
    error_box.setAlignment(Pos.CENTER);
    error_box.getChildren().add(error);
    gp.add(error_box, 0, 4, 2, 1);

    Button finish = new Button("Finish");
    finish.setDisable(true);
    HBox center_button = new HBox(10);
    center_button.setAlignment(Pos.CENTER);
    center_button.getChildren().add(finish);
    gp.add(center_button, 0, 5, 2, 1);

    ChangeListener name = new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            finish.setDisable(true);
            if (usernamefield.getText().equals("")) {
                error.setFill(Color.RED);
                error.setText("Username can not be blank!");
            }
            if (!passwordfield.getText().equals(r_passwordfield.getText())) {
                error.setFill(Color.RED);
                error.setText("Passwords do not match!");
            }
            if (passwordfield.getText().equals("") && r_passwordfield.getText().equals("")) {
                error.setFill(Color.RED);
                error.setText("Passwords can not be blank!");
            }
            if (passwordfield.getText().equals(r_passwordfield.getText()) && !usernamefield.getText().equals("")
                    && !passwordfield.getText().equals("")) {
                error.setFill(Color.GREEN);
                error.setText("No issues.");
                finish.setDisable(false);
            }
        }

    };

    usernamefield.textProperty().addListener(name);
    passwordfield.textProperty().addListener(name);
    r_passwordfield.textProperty().addListener(name);

    finish.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {

            users.remove(usernamefield.getText());
            users.add(usernamefield.getText());
            userpasswords.put(usernamefield.getText(), passwordfield.getText());
            to_update.setItems(FXCollections.observableArrayList(users));

            createAccountStage.close();
        }

    });

    //Creates the scene
    Scene scene = new Scene(gp, 300, 275);
    scene.getStylesheets().add(this.getClass().getResource("login_css.css").toExternalForm());

    createAccountStage.setScene(scene);
    createAccountStage.show();

}

From source file:com.helegris.szorengeteg.ui.forms.TopicFormView.java

private void bulkAddAudio() {
    if (sortedRows.size() > 0) {
        Stage stage = new Stage();
        BulkAddAudioView view = new BulkAddAudioView(sortedRows);
        stage.setScene(new SceneStyler().createScene(view, SceneStyler.Style.TOPIC_LIST));
        stage.setTitle(Messages.msg("form.bulk_add_something", Messages.msg("form.audio")));
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.initOwner(getScene().getWindow());
        stage.showAndWait();/*  w ww .  j a  v a  2  s.  c o m*/

        if (view.isOk()) {
            view.getFiles().entrySet().stream().forEach((entry) -> {
                ((RowForCard) sortedRows.get(entry.getKey())).setAudioFile(entry.getValue());
            });
            view.getAudio().entrySet().stream().forEach((entry) -> {
                ((RowForCard) sortedRows.get(entry.getKey())).setAudio(entry.getValue());
            });
        }
    } else {
        Alert alert = new Alert(Alert.AlertType.WARNING);
        alert.setTitle(Messages.msg("alert.error"));
        alert.setHeaderText(Messages.msg("alert.no_words_audio"));
        alert.setContentText(Messages.msg("alert.add_words"));
        alert.showAndWait();
    }
}

From source file:org.ado.biblio.desktop.AppPresenter.java

public void linkAndroid() {
    final AndroidView androidView = new AndroidView();
    Stage stage = new Stage();
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setScene(new Scene(androidView.getView()));
    stage.setTitle("Android");
    stage.show();/* ww  w.j a va 2s.co  m*/
}

From source file:de.micromata.mgc.javafx.launcher.gui.AbstractMainWindow.java

@FXML
private void openConfigDialog(ActionEvent event) {
    Pair<Pane, ? extends AbstractConfigDialog<M>> load = loadConfigDialog();
    Pane root = load.getKey();/*from  w  w  w  . j a  v a2s . c om*/
    AbstractConfigDialog<M> controller = load.getValue();
    controller.mainWindow = this;

    controller.getStage().addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, e -> {
        controller.closeDialog();
        e.consume();
    });

    controller.getStage().initModality(Modality.APPLICATION_MODAL);
    controller.getStage().setWidth(800);
    controller.getStage().setHeight(600);

    controller.getStage().setTitle("Configuration");
    controller.getStage().show();

}

From source file:org.ado.biblio.desktop.AppPresenter.java

public void linkDropbox() throws DropboxException {
    Stage stage = new Stage();
    DropboxView dropboxView = new DropboxView();
    final DropboxPresenter dropboxPresenter = (DropboxPresenter) dropboxView.getPresenter();
    dropboxPresenter.setStage(stage);//from w  ww . ja v  a 2s.co m
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setScene(new Scene(dropboxView.getView()));
    stage.setTitle("Dropbox");
    stage.show();
}

From source file:org.ado.biblio.desktop.AppPresenter.java

public void settings() {
    Stage stage = new Stage();
    final SettingsView settingsView = new SettingsView();
    final SettingsPresenter presenter = (SettingsPresenter) settingsView.getPresenter();
    presenter.setStage(stage);//from  w w w .  java2  s.  co  m
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setScene(new Scene(settingsView.getView()));
    stage.setTitle("Settings");
    stage.show();
}