Example usage for javafx.stage Stage Stage

List of usage examples for javafx.stage Stage Stage

Introduction

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

Prototype

public Stage() 

Source Link

Document

Creates a new instance of decorated Stage .

Usage

From source file:tachyon.view.ProjectProperties.java

public ProjectProperties(JavaProject project, Window w) {
    this.project = project;
    stage = new Stage();
    stage.initOwner(w);//from  w ww  .  j  a va2  s .  c  om
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setWidth(600);
    stage.setTitle("Project Properties - " + project.getProjectName());
    stage.getIcons().add(tachyon.Tachyon.icon);
    stage.setResizable(false);
    HBox mai, libs, one, two, thr, fou;
    ListView<String> compileList, runtimeList;
    Button compileAdd, compileRemove, preview, selectIm, runtimeAdd, runtimeRemove;
    TextField iconField;
    stage.setScene(new Scene(new VBox(5, pane = new TabPane(
            new Tab("Library Settings",
                    box1 = new VBox(15,
                            libs = new HBox(10, new Label("External Libraries"), libsView = new ListView<>(),
                                    new VBox(5, addJar = new Button("Add Jar"),
                                            removeJar = new Button("Remove Jar"))))),
            new Tab("Program Settings",
                    new ScrollPane(box2 = new VBox(15, one = new HBox(10, new Label("Main-Class"),
                            mainClass = new TextField(project.getMainClassName()),
                            select = new Button("Select")),
                            two = new HBox(10, new Label("Compile-Time Arguments"),
                                    compileList = new ListView<>(),
                                    new VBox(5, compileAdd = new Button("Add Argument"),
                                            compileRemove = new Button("Remove Argument")))))),
            new Tab("Deployment Settings",
                    box3 = new VBox(15, thr = new HBox(10, new Label("Icon File"),
                            iconField = new TextField(project.getFileIconPath()),
                            preview = new Button("Preview Image"), selectIm = new Button("Select Icon")),
                            fou = new HBox(10, new Label("Runtime Arguments"), runtimeList = new ListView<>(),
                                    new VBox(5, runtimeAdd = new Button("Add Argument"),
                                            runtimeRemove = new Button("Remove Argument")))))),
            new VBox(15, mai = new HBox(10, cancel = new Button("Cancel"), confirm = new Button("Confirm"))))));
    if (applyCss.get()) {
        stage.getScene().getStylesheets().add(css);
    }
    for (Tab b : pane.getTabs()) {
        b.setClosable(false);
    }
    mainClass.setPromptText("Main-Class");
    box1.setPadding(new Insets(5, 10, 5, 10));
    mai.setAlignment(Pos.CENTER_RIGHT);
    mai.setPadding(box1.getPadding());
    libs.setAlignment(Pos.CENTER);
    one.setAlignment(Pos.CENTER);
    two.setAlignment(Pos.CENTER);
    thr.setAlignment(Pos.CENTER);
    fou.setAlignment(Pos.CENTER);
    box1.setAlignment(Pos.CENTER);
    box2.setPadding(box1.getPadding());
    box2.setAlignment(Pos.CENTER);
    box3.setPadding(box1.getPadding());
    box3.setAlignment(Pos.CENTER);
    mainClass.setEditable(false);
    mainClass.setPrefWidth(200);
    for (JavaLibrary lib : project.getAllLibs()) {
        libsView.getItems().add(lib.getBinaryAbsolutePath());
    }
    for (String sa : project.getCompileTimeArguments().keySet()) {
        compileList.getItems().add(sa + ":" + project.getCompileTimeArguments().get(sa));
    }
    for (String sa : project.getRuntimeArguments()) {
        runtimeList.getItems().add(sa);
    }
    compileAdd.setOnAction((e) -> {
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("Compiler Argument");
        dialog.initOwner(stage);
        dialog.setHeaderText("Entry the argument");

        ButtonType loginButtonType = new ButtonType("Done", ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField username = new TextField();
        username.setPromptText("Key");
        TextField password = new TextField();
        password.setPromptText("Value");

        grid.add(new Label("Key:"), 0, 0);
        grid.add(username, 1, 0);
        grid.add(new Label("Value:"), 0, 1);
        grid.add(password, 1, 1);

        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);

        username.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().isEmpty());
        });

        dialog.getDialogPane().setContent(grid);

        Platform.runLater(() -> username.requestFocus());

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(username.getText(), password.getText());
            }
            return null;
        });

        Optional<Pair<String, String>> result = dialog.showAndWait();
        if (result.isPresent()) {
            compileList.getItems().add(result.get().getKey() + ":" + result.get().getValue());
        }
    });
    compileRemove.setOnAction((e) -> {
        if (compileList.getSelectionModel().getSelectedItem() != null) {
            compileList.getItems().remove(compileList.getSelectionModel().getSelectedItem());
        }
    });
    runtimeAdd.setOnAction((e) -> {
        TextInputDialog dia = new TextInputDialog();
        dia.setTitle("Add Runtime Argument");
        dia.setHeaderText("Enter an argument");
        dia.initOwner(stage);
        Optional<String> res = dia.showAndWait();
        if (res.isPresent()) {
            runtimeList.getItems().add(res.get());
        }
    });
    runtimeRemove.setOnAction((e) -> {
        if (runtimeList.getSelectionModel().getSelectedItem() != null) {
            runtimeList.getItems().remove(runtimeList.getSelectionModel().getSelectedItem());
        }
    });
    preview.setOnAction((e) -> {
        if (!iconField.getText().isEmpty()) {
            if (iconField.getText().endsWith(".ico")) {
                List<BufferedImage> read = new ArrayList<>();
                try {
                    read.addAll(ICODecoder.read(new File(iconField.getText())));
                } catch (IOException ex) {
                }
                if (read.size() >= 1) {
                    Image im = SwingFXUtils.toFXImage(read.get(0), null);
                    Stage st = new Stage();
                    st.initOwner(stage);
                    st.initModality(Modality.APPLICATION_MODAL);
                    st.setTitle("Icon Preview");
                    st.getIcons().add(Tachyon.icon);
                    st.setScene(new Scene(new BorderPane(new ImageView(im))));
                    if (applyCss.get()) {
                        st.getScene().getStylesheets().add(css);
                    }
                    st.showAndWait();
                }
            } else if (iconField.getText().endsWith(".icns")) {
                try {
                    BufferedImage ima = Imaging.getBufferedImage(new File(iconField.getText()));
                    if (ima != null) {
                        Image im = SwingFXUtils.toFXImage(ima, null);
                        Stage st = new Stage();
                        st.initOwner(stage);
                        st.initModality(Modality.APPLICATION_MODAL);
                        st.setTitle("Icon Preview");
                        st.getIcons().add(Tachyon.icon);
                        st.setScene(new Scene(new BorderPane(new ImageView(im))));
                        if (applyCss.get()) {
                            st.getScene().getStylesheets().add(css);
                        }
                        st.showAndWait();
                    }
                } catch (ImageReadException | IOException ex) {
                }
            } else {
                Image im = new Image(new File(iconField.getText()).toURI().toString());
                Stage st = new Stage();
                st.initOwner(stage);
                st.initModality(Modality.APPLICATION_MODAL);
                st.setTitle("Icon Preview");
                st.getIcons().add(Tachyon.icon);
                st.setScene(new Scene(new BorderPane(new ImageView(im))));
                if (applyCss.get()) {
                    st.getScene().getStylesheets().add(css);
                }
                st.showAndWait();
            }
        }
    });
    selectIm.setOnAction((e) -> {
        FileChooser fc = new FileChooser();
        fc.setTitle("Icon File");
        String OS = System.getProperty("os.name").toLowerCase();
        fc.getExtensionFilters().add(new ExtensionFilter("Icon File",
                OS.contains("win") ? getWindowsImageExtensions() : getMacImageExtensions()));
        fc.setSelectedExtensionFilter(fc.getExtensionFilters().get(0));
        File lf = fc.showOpenDialog(stage);
        if (lf != null) {
            iconField.setText(lf.getAbsolutePath());
        }
    });

    addJar.setOnAction((e) -> {
        FileChooser f = new FileChooser();
        f.setTitle("External Libraries");
        f.setSelectedExtensionFilter(new ExtensionFilter("Jar Files", "*.jar"));
        List<File> showOpenMultipleDialog = f.showOpenMultipleDialog(stage);
        if (showOpenMultipleDialog != null) {
            for (File fi : showOpenMultipleDialog) {
                if (!libsView.getItems().contains(fi.getAbsolutePath())) {
                    libsView.getItems().add(fi.getAbsolutePath());
                }
            }
        }
    });

    removeJar.setOnAction((e) -> {
        String selected = libsView.getSelectionModel().getSelectedItem();
        if (selected != null) {
            libsView.getItems().remove(selected);
        }
    });

    select.setOnAction((e) -> {
        List<String> all = getAll();
        ChoiceDialog<String> di = new ChoiceDialog<>(project.getMainClassName(), all);
        di.setTitle("Select Main Class");
        di.initOwner(stage);
        di.setHeaderText("Select A Main Class");
        Optional<String> show = di.showAndWait();
        if (show.isPresent()) {
            mainClass.setText(show.get());
        }
    });
    cancel.setOnAction((e) -> {
        stage.close();
    });
    confirm.setOnAction((e) -> {
        project.setMainClassName(mainClass.getText());
        project.setFileIconPath(iconField.getText());
        project.setRuntimeArguments(runtimeList.getItems());
        HashMap<String, String> al = new HashMap<>();
        for (String s : compileList.getItems()) {
            String[] spl = s.split(":");
            al.put(spl[0], spl[1]);
        }
        project.setCompileTimeArguments(al);
        project.setAllLibs(libsView.getItems());
        stage.close();
    });
}

From source file:org.mskcc.shenkers.control.track.fasta.FastaViewNGTest.java

@Test
public void testGetGraphic() throws InterruptedException {
    String title = "";
    CountDownLatch l = new CountDownLatch(1);
    Platform.runLater(() -> {//from   w  ww  .  ja  v  a  2 s . c  om
        String st = "CGATCGCCATTGAGCAAGTAAGCCAACTTTCGGCTCGCGTGTACGCGATAAGTAGGTGCCCTCTGCATCCGACGCACTTCAGCCGAACCACTTGCGGGAATTTGGGGGAGTGCTGATACGACGGCATAGGAATGGAGCTCTTTAAGTGCGTCTACACACGGACCGTACTTGGCCAAATCGGCAGTCAGTTGTATT";
        FastaView tp = new FastaView();
        tp.flip.setValue(true);
        tp.setSequence(0, st);

        Scene scene = new Scene(tp, 300, 300, Color.GRAY);
        Stage stage = new Stage();
        stage.setScene(scene);

        stage.setOnHidden(e -> {
            l.countDown();
        });
        stage.show();

    });
    l.await();
}

From source file:jlotoprint.MainViewController.java

public static Stage loadTemplateChooser() {
    final Stage stage = new Stage();
    try {//from  w ww.  j  a  v a2 s  .c o  m
        FXMLLoader dialog = new FXMLLoader(MainViewController.class.getResource("TemplateDialog.fxml"));
        Parent root = (Parent) dialog.load();
        root.addEventHandler(TemplateDialogEvent.CANCELED, (actionEvent) -> {
            stage.close();
        });
        stage.setScene(new Scene(root));
        stage.setTitle("Choose a template");
        stage.getIcons().add(new Image("file:resources/icon.png"));
        stage.initModality(Modality.WINDOW_MODAL);
        stage.initOwner(JLotoPrint.stage.getScene().getWindow());
        stage.show();
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        return null;
    }
    return stage;
}

From source file:account.management.controller.ViewSalaryVoucherController.java

/**
 * Initializes the controller class./*  w  w w  . j a  va 2s .  c o  m*/
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    this.voucher_no.setCellValueFactory(new PropertyValueFactory("id"));
    this.date.setCellValueFactory(new PropertyValueFactory("date"));
    this.section.setCellValueFactory(new PropertyValueFactory("section"));
    this.name.setCellValueFactory(new PropertyValueFactory("name"));
    this.basis.setCellValueFactory(new PropertyValueFactory("basis"));
    this.amount.setCellValueFactory(new PropertyValueFactory("total"));

    final ContextMenu contextMenu = new ContextMenu();
    MenuItem item1 = new MenuItem("    View                  ");
    item1.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent e) {
            Data.salaryVoucher = table.getSelectionModel().getSelectedItem();

            try {
                Parent root = FXMLLoader
                        .load(getClass().getResource(MetaData.viewPath + "EditSalaryVoucher.fxml"));
                Scene scene = new Scene(root);
                Stage stage = new Stage();
                scene.setRoot(root);
                stage.setResizable(false);
                stage.setTitle("Salary Voucher");
                stage.setScene(scene);
                stage.showAndWait();
                int index = table.getSelectionModel().getSelectedIndex();
                getData();

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

        }
    });
    contextMenu.getItems().addAll(item1);
    this.table.setContextMenu(contextMenu);

}

From source file:org.mskcc.shenkers.view.IntervalViewNGTest.java

public void testRangeSetIntervalView() throws InterruptedException {
    System.out.println("testIntervalView");

    CountDownLatch l = new CountDownLatch(1);
    System.out.println("before");
    Platform.runLater(() -> {//from   www.  j  av a2  s .co  m
        System.out.println("running");
        double[][] intervals = { { .1, .2 } };
        //                    Range r = null;
        RangeSet<Double> rs = TreeRangeSet.create();
        rs.add(Range.closed(.1, .2));
        rs.add(Range.closed(.2, .3));
        rs.add(Range.closed(.32, .35));
        rs.add(Range.closed(.6, .8));

        RangeSetIntervalView p = new RangeSetIntervalView(0, 100);
        p.setData(Arrays.asList(new Pair(10, 20), new Pair(20, 30), new Pair(32, 35), new Pair(60, 80)));

        //                    p.prefTileHeightProperty().bind(p.heightProperty());
        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
            System.out.println("count " + l.getCount());
        });
        Scene scene = new Scene(p, 300, 300, Color.GRAY);
        stage.setTitle("SimpleIntervalView");
        stage.setScene(scene);
        stage.show();

    });
    System.out.println("after");
    l.await();
    Thread.sleep(1000);
}

From source file:at.ac.tuwien.qse.sepm.gui.FullscreenWindow.java

@FXML
private void initialize() {
    this.stage = new Stage();
    this.scene = new Scene(this);

    stage.setScene(scene);//from  ww  w  . j av  a2  s  .c o m

    image.setPreserveRatio(true);
    getChildren().add(0, image);

    hideButton.setOnAction((e) -> menu.setOpacity(0.0));
    menu.setOnMouseEntered(e -> menu.setOpacity(1.0));

    root.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(final KeyEvent keyEvent) {
            if (keyEvent.getCode() == KeyCode.RIGHT) {
                bt_nextPressed(null);
            }
            if (keyEvent.getCode() == KeyCode.LEFT) {
                bt_previousPressed(null);
            }
            if (keyEvent.getCode() == KeyCode.ESCAPE) {
                stage.close();
            }
            if (keyEvent.getCode() == KeyCode.DIGIT1) {
                ratingPicker.setRating(Rating.BAD);
            }
            if (keyEvent.getCode() == KeyCode.DIGIT2) {
                ratingPicker.setRating(Rating.NEUTRAL);
            }
            if (keyEvent.getCode() == KeyCode.DIGIT3) {
                ratingPicker.setRating(Rating.GOOD);
            }
        }
    });

    ratingPicker.setRatingChangeHandler(this::handleRatingChange);
}

From source file:com.toyota.carservice.config.config2.java

public Object newStage3(Stage stage, Label lb, String load, String judul, boolean resize, StageStyle style,
        boolean maximized) {
    try {/*w ww  .ja  v  a  2s .c om*/
        Stage st = new Stage();
        stage = (Stage) lb.getScene().getWindow();
        FXMLLoader root = new FXMLLoader(getClass().getResource(load));

        Scene scene = new Scene(root.load());
        st.initStyle(style);
        st.setResizable(resize);
        st.setMaximized(maximized);
        st.setTitle(judul);
        st.setScene(scene);
        ApplicationContext appContex = config.getInstance().getApplicationContext();
        Resource resource = appContex.getResource("classpath:com/toyota/carservice/img/kallatoyota.png");
        st.getIcons().add(new Image(resource.getURI().toString()));
        st.show();
        return root.getController();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:ui.ChoseFonctionnalite.java

private void startClientMode(ActionEvent eventT) {
    //File config = new File("resource/config.json");
    String host = "";
    String port = "8000";
    Stage stageModal = new Stage();
    Pane root = new Pane();
    root.setBackground(new Background(new BackgroundImage(new Image("resource/background.jpg"),
            BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
            new BackgroundSize(530, 400, true, true, true, true))));
    stageModal.setScene(new Scene(root, 200, 200));
    stageModal.initStyle(StageStyle.UTILITY);
    Label adresse = new Label("Adresse serveur:");
    adresse.setLayoutX(10);/*from   w ww . j a v  a2  s  .  c  o  m*/
    adresse.setLayoutY(10);
    adresse.setFont(Font.font("Arial", 16));
    JFXTextField adresseInput = new JFXTextField("127.0.0.1");
    adresseInput.setPrefWidth(180);
    adresseInput.setLayoutX(10);
    adresseInput.setLayoutY(40);
    JFXButton valider = new JFXButton("Se connecter");
    valider.setCursor(Cursor.HAND);
    valider.setMinSize(100, 30);
    valider.setLayoutX(20);
    valider.setLayoutY(130);
    valider.setFont(new Font(20));
    valider.setStyle("-fx-background-color: #9E21FF;");
    valider.setOnAction(event -> {
        if (adresseInput.getText() != "") {
            stageModal.close();
            InitClient initializeClient = new InitClient(stage, adresseInput.getText(), port);
        }
    });
    root.getChildren().add(valider);
    root.getChildren().add(adresse);
    root.getChildren().add(adresseInput);
    stageModal.setTitle("Adresse serveur");
    stageModal.initModality(Modality.WINDOW_MODAL);
    stageModal.initOwner(((Node) eventT.getSource()).getScene().getWindow());
    stageModal.show();
}

From source file:UI.MainPageController.java

/**
 * This will select the file to say to and then call the pdf's build function
 * to export the updated pdf/*from  w  w w .  ja v a 2s.  co m*/
 */
@FXML
private void exportPDFPress() {
    FileChooser chooser = new FileChooser();
    File file = chooser.showSaveDialog(new Stage());

    if (file == null) {
        showWarning("No file selected or created");
        filename = "";
    } else {
        try {
            if (!file.exists()) {
                file.createNewFile();
            }
        } catch (Exception e) {
            ;
        }
        filename = file.getPath();
        try {
            pdf.buildPDF(filename);
        } catch (Exception e) {
            System.out.println("Export PDF FAIL");
        }
    }
}

From source file:com.ggvaidya.scinames.summary.HigherStabilityView.java

public HigherStabilityView(ProjectView pv) {
    projectView = pv;//from w  w w . j  a va  2 s .  com
    stage = new Stage();

    controller = TabularDataViewController.createTabularDataView();
    scene = controller.getScene();
    init();

    // Go go stagey scene.
    stage.setScene(scene);
}