Example usage for javafx.stage Stage initModality

List of usage examples for javafx.stage Stage initModality

Introduction

In this page you can find the example usage for javafx.stage Stage initModality.

Prototype

public final void initModality(Modality modality) 

Source Link

Document

Specifies the modality for this stage.

Usage

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();/*from  ww w .ja  va2 s .  c o m*/
}

From source file:ExcelFx.FXMLDocumentController.java

@Override
public void initialize(URL url, ResourceBundle rb) {

    this.Print.setDisable(true);

    footer.setItems(names);/*from   w ww .j a  va2s.com*/
    JsonWrite jsw = new JsonWrite();
    File universityFile = new File("university.json");
    File collegeFile = new File("college.json");
    //File codesFile = new File("codes.json");

    if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) {
        try {
            this.universityJson.jsonRead("university.json");
            this.collegeJson.jsonRead("college.json");
            //this.codesJson.jsonRead("codes.json");
            this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
        } catch (IOException | ParseException ex) {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("");
            alert.setHeaderText(" ? ? ");
            alert.setContentText(ex.toString());
            alert.showAndWait();
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }

    } else {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FileOpenFXML.fxml"));
            this.fileOpenParent = (Parent) fxmlLoader.load();
            Stage stage = new Stage();
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initStyle(StageStyle.DECORATED);
            stage.setTitle(" ");
            stage.setScene(new Scene(this.fileOpenParent));

            stage.showAndWait();
        } catch (Exception e) {
            System.err.println(e);

        }

        this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
    }

}

From source file:main.Content.java

public boolean showInputDialog(Activity aktivitet) {
    try {//from   w w  w . j ava  2  s .co m
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(Main.class.getResource("view/InputDialog.fxml"));
        AnchorPane page = (AnchorPane) loader.load();

        Stage dialogStage = new Stage();
        dialogStage.setTitle("Data Input");
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.initOwner(mainApp.getPrimaryStage());
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        InputDialogController controller = loader.getController();
        controller.setListData(data);
        controller.setDialogStage(dialogStage);
        controller.setData(aktivitet);

        dialogStage.showAndWait();

        return controller.isSaveClicked();
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
}

From source file:ca.wumbo.doommanager.client.controller.FileEditorController.java

/**
 * Creates a new DXML project and has the user set it up, then places it in
 * the tab.//w  w w .java 2s.  co m
 */
public void newDXMLProject() {
    // Create the wizard and wait for the result.
    DXMLProjectCreatorController controller = SpringContainer.getContext()
            .getBean(DXMLProjectCreatorController.class);

    Scene scene = new Scene(controller.getRootPane());
    scene.getStylesheets().add(cssPath);

    Stage stage = new Stage();
    stage.setTitle("DXML Project Setup Wizard");
    stage.setResizable(false);
    stage.initModality(Modality.WINDOW_MODAL);
    stage.initOwner(coreController.getStage());
    stage.setScene(scene);
    controller.setStage(stage); // Required for it to be able to close properly.
    controller.setParentStage(coreController.getStage()); // Required as well to block input if browsing for files.
    stage.showAndWait();

    // If the user finished the work, get the DXML file.
    if (!controller.wasClosedByUser()) {
        DXML dxmlData = controller.getDxmlData();
        // The file must also be valid. This should not ever be false unless there is a coding error.
        if (dxmlData.isValidDXMLFile()) {
            // Create it on the disk.
            DXMLCreationStatus status = dxmlData.createOnDisk();

            // If the status shows success, add it to the view.
            switch (status) {
            case SUCCESS:
                // Since it succeeded, open up the project now.
                String path = dxmlData.getProjectInfo().getProjectLocationPath() + File.separator;
                path += dxmlData.getCompilation().getFilename() + File.separator;
                path += dxmlData.getCompilation().getFilename() + ".dxml"; // TODO - support any case extension.
                openDXMLProject(Paths.get(path));
                break;
            case ALREADY_EXISTS:
                log.warn("DXML project already exists at the specified location. Aborting.");
                break;
            case FOLDER_CREATION_FAILURE:
                log.warn("Unable to create directory for the project. Are your permissions correct? Aborting.");
                break;
            case DXML_FILE_EXISTS:
                log.warn("DXML file already exists at location, aborting to prevent potential overwrite.");
                break;
            case DXML_FILE_CREATION_FAILURE:
                log.warn("Unable to create DXML file at location, are your permissions correct? Aborting.");
                break;
            case XML_MARSHALL_ERROR:
                log.warn("Unable to create the .dxml file. Are your file permissions correct? Aborting.");
                break;
            case FAILED:
                log.warn("Unable to create the necessary DXML file/folder resources at the provided location.");
                break;
            case INVALID_DXML_DATA:
            case BAD_PROJECT_PATH:
                log.warn("DXML project has corrupt data. Contact a developer, Aborting [Reason: {}].",
                        status.name());
                break;
            default:
                throw new DXMLException(
                        "DXML status for disk creation returned an unexpected enumeration. Contact a developer.");
            }
        } else {
            throw new DXMLException(
                    "DXML Wizard has not properly generated a proper file. Please contact a developer.");
        }
    } else {
        log.info("DXML project cancelled by user.");
    }
}

From source file:ExcelFx.FXMLDocumentController.java

@FXML
private void Open(ActionEvent event) throws NullPointerException, IOException {

    System.out.println("-----------------------------------------------------------");
    System.out.println("Pressed open Button ");
    File universityFile = new File("university.json");
    File collegeFile = new File("college.json");
    System.out.println("University File emty is " + String.valueOf(universityFile.length() == 0));
    System.out.println("College File emty is " + String.valueOf(collegeFile.length() == 0));

    //File codesFile = new File("codes.json");
    if ((universityFile.exists()) && (collegeFile.exists()) /*&& (codesFile.exists())*/) {
        try {/*  ww w  .  j a  v  a2  s  . c  o m*/
            this.universityJson.jsonRead("university.json");
            this.collegeJson.jsonRead("college.json");
            //this.codesJson.jsonRead("codes.json");
            this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
        } catch (IOException | ParseException ex) {
            Alert alert = new Alert(Alert.AlertType.INFORMATION);
            alert.setTitle("");
            alert.setHeaderText(" ? ? ");
            alert.setContentText(ex.toString());
            alert.showAndWait();
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }

    } else {
        try {
            FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("FileOpenFXML.fxml"));
            this.fileOpenParent = (Parent) fxmlLoader.load();
            Stage stage = new Stage();
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initStyle(StageStyle.DECORATED);
            stage.setTitle(" ");
            stage.setScene(new Scene(this.fileOpenParent));

            stage.showAndWait();
        } catch (Exception e) {
            System.err.println(e);

        }

        this.jsonXLSXData.setAll(universityJson, collegeJson/*, codesJson*/);
    }

    FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("InitalData.fxml"));
    Parent root1 = (Parent) fxmlLoader.load();
    Stage stage = new Stage();
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.initStyle(StageStyle.DECORATED);

    stage.setTitle(" ");
    stage.setScene(new Scene(root1));
    stage.showAndWait();
    setProgressBar(-1.);

    Task task = new Task<Void>() {

        @Override
        protected Void call() throws Exception {

            initaldata = (JsonWrite) root1.getUserData();
            System.out.println("Inital Data empty is " + initaldata.isEmpty());

            initaldata.setPage(String.valueOf(Integer.parseInt(initaldata.getPage()) - 1));

            Parser parser = new Parser();

            list = parser.parseInitalData(initaldata.getPatch(), Integer.parseInt(initaldata.getPage()));
            //System.out.println(list.size());
            Sort sort = new Sort(list, jsonXLSXData, initaldata.getYStart(), initaldata.getYEnd());
            HashMap<String, HashMap<String, ArrayList<String>>> hm = sort
                    .professionsGrouping(initaldata.getYStart(), initaldata.getYEnd());

            sortProf = sort.addWay(hm);

            return null;
        }

    };
    mainProcessing(task);

    System.out.println("button open finished");
    System.out.println("-----------------------------------------------------------");

}

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

private void createBannedIP(ListView<String> to_update) {
    Stage createBannedIP = new Stage();
    createBannedIP.setTitle("Add Banned IP");
    createBannedIP.initModality(Modality.APPLICATION_MODAL);

    GridPane gp = new GridPane();
    gp.setPadding(new Insets(25, 25, 25, 25));
    gp.setAlignment(Pos.CENTER);//  www  .  j  a  va  2 s .com
    gp.setVgap(10);
    gp.setHgap(10);

    Text title = new Text("Add Banned IP");
    title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20));
    gp.add(title, 0, 0, 2, 1);

    Label newusername = new Label("Ban IP");
    TextField username = new TextField();
    gp.add(newusername, 0, 1);
    gp.add(username, 1, 1);

    Button finish = new Button("Finish");
    HBox finish_box = new HBox(10);
    finish_box.setAlignment(Pos.CENTER);
    finish_box.getChildren().add(finish);

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

        @Override
        public void handle(ActionEvent event) {
            banned_ips.remove(username.getText());
            banned_ips.add(username.getText());
            to_update.setItems(FXCollections.observableArrayList(banned_ips));
            createBannedIP.close();
        }

    });

    gp.add(finish_box, 0, 2, 2, 1);

    Scene sc = new Scene(gp, 300, 175);
    createBannedIP.setScene(sc);
    createBannedIP.show();
}

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

private void createBannedUser(ListView<String> to_update) {
    Stage createBannedUser = new Stage();
    createBannedUser.setTitle("Add Banned User");
    createBannedUser.initModality(Modality.APPLICATION_MODAL);

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

    Text title = new Text("Add Banned Username");
    title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20));
    gp.add(title, 0, 0, 2, 1);

    Label newusername = new Label("Ban Username");
    TextField username = new TextField();
    gp.add(newusername, 0, 1);
    gp.add(username, 1, 1);

    Button finish = new Button("Finish");
    HBox finish_box = new HBox(10);
    finish_box.setAlignment(Pos.CENTER);
    finish_box.getChildren().add(finish);

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

        @Override
        public void handle(ActionEvent event) {
            banned_usernames.remove(username.getText());
            banned_usernames.add(username.getText());
            to_update.setItems(FXCollections.observableArrayList(banned_usernames));
            createBannedUser.close();
        }

    });

    gp.add(finish_box, 0, 2, 2, 1);

    Scene sc = new Scene(gp, 300, 175);
    createBannedUser.setScene(sc);
    createBannedUser.show();
}

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);//from w  w  w. j  av  a 2 s .c  om
    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:gov.va.isaac.sync.view.SyncView.java

/**
 * @see gov.va.isaac.interfaces.gui.views.PopupViewI#showView(javafx.stage.Window)
 *//* w  w w.  ja v a2 s .  co m*/
@Override
public void showView(Window parent) {
    initGui();
    Stage stage = new Stage(StageStyle.DECORATED);
    stage.initModality(Modality.NONE);
    stage.initOwner(parent);
    Scene scene = new Scene(root_);
    stage.setScene(scene);
    stage.setTitle("Datastore Synchronization");
    stage.getScene().getStylesheets().add(SyncView.class.getResource("/isaac-shared-styles.css").toString());
    stage.sizeToScene();
    stage.show();
    stage.setOnCloseRequest(windowEvent -> {
        if (running_.get()) {
            windowEvent.consume();
        }
    });
}

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

private void createBannedPlayername(ListView<String> to_update) {
    Stage createBannedPlayername = new Stage();
    createBannedPlayername.setTitle("Add Banned Playername");
    createBannedPlayername.initModality(Modality.APPLICATION_MODAL);

    GridPane gp = new GridPane();
    gp.setPadding(new Insets(25, 25, 25, 25));
    gp.setAlignment(Pos.CENTER);/* ww  w  .j a  v a  2  s.co  m*/
    gp.setVgap(10);
    gp.setHgap(10);

    Text title = new Text("Add Banned Playername");
    title.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20));
    gp.add(title, 0, 0, 2, 1);

    Label newusername = new Label("Ban Playername");
    TextField username = new TextField();
    gp.add(newusername, 0, 1);
    gp.add(username, 1, 1);

    Button finish = new Button("Finish");
    HBox finish_box = new HBox(10);
    finish_box.setAlignment(Pos.CENTER);
    finish_box.getChildren().add(finish);

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

        @Override
        public void handle(ActionEvent event) {
            banned_playernames.remove(username.getText());
            banned_playernames.add(username.getText());
            to_update.setItems(FXCollections.observableArrayList(banned_playernames));
            createBannedPlayername.close();
        }

    });

    gp.add(finish_box, 0, 2, 2, 1);

    Scene sc = new Scene(gp, 300, 175);
    createBannedPlayername.setScene(sc);
    createBannedPlayername.show();
}