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:fruitproject.FruitProject.java

public void third(final String pfname) {
    final Stage st = new Stage();
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);/*  w w w  .  j a va  2s . co  m*/
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Label label1 = new Label("New Fruit");
    grid.add(label1, 1, 0);
    final TextField txtName = new TextField();
    grid.add(txtName, 1, 1);
    final TextField txtAmount = new TextField();
    grid.add(txtAmount, 1, 2);
    Button btn = new Button();
    btn.setText("OK");
    grid.add(btn, 1, 3);
    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            //System.out.println("Hello World!");
            addPairs.add(txtName.getText());
            addPairs.add(txtAmount.getText());
            st.close();
            second(pfname);
        }
    });

    Scene scene = new Scene(grid, 500, 500);
    st.setScene(scene);
    st.show();

}

From source file:ui.main.MainViewController.java

@FXML
public void handleEditMyAccountMenuCall(ActionEvent event) {
    try {//  w  w w  .ja v a2s .c o m
        //default configuration and initialization of the form
        Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui/account/AccountView.fxml"));

        Scene scene = new Scene(root);

        Stage stage = new Stage();

        stage.setScene(scene);
        stage.show();

        stage.setResizable(false);
        stage.setTitle("IMP");
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

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

public void about() {
    LOGGER.info("about");
    Stage stage = new Stage();
    final AboutView aboutView = new AboutView();
    final AboutPresenter presenter = (AboutPresenter) aboutView.getPresenter();
    presenter.setStage(stage);//from   w  ww.  j a va  2  s. c  o  m
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setScene(new Scene(aboutView.getView()));
    stage.setTitle("About");
    stage.show();
}

From source file:ui.main.MainViewController.java

@FXML
public void handleContactMenuCall(ActionEvent event) {
    //this method displays the contact view
    try {/*from  w  w  w . jav a 2s .  c  o  m*/
        //default configuration and initialization of the form
        Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("ui/contacts/ContactsView.fxml"));

        Scene scene = new Scene(root);

        Stage stage = new Stage();

        stage.setScene(scene);
        stage.show();

        stage.setResizable(false);
        stage.setTitle("IMP : Contacts");
    } catch (IOException ex) {
        Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:mesclasses.view.TimetableController.java

private Cours openEditDialog(Cours coursToEdit, Cours originalCours) {
    try {//  w  ww  . j  a v a2s.co m
        // Load the fxml file and create a new stage for the popup dialog.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(MainApp.class.getResource(Constants.COURS_EDIT_DIALOG));
        AnchorPane page = (AnchorPane) loader.load();

        // Create the dialog Stage.
        Stage dialogStage = new Stage();
        dialogStage.setTitle("Edition d'un cours");
        dialogStage.initModality(Modality.WINDOW_MODAL);
        dialogStage.initOwner(primaryStage);
        Scene scene = new Scene(page);
        dialogStage.setScene(scene);

        // Set the person into the controller.
        CoursEditDialogController controller = loader.getController();
        controller.setDialogStage(dialogStage);
        controller.setCours(coursToEdit, false);

        // Show the dialog and wait until the user closes it
        dialogStage.showAndWait();
        int status = controller.getStatus();
        if (status >= 0) {
            //update/cancel
            return controller.getCours();
        } else {
            //delete
            getPane(coursToEdit).getChildren().remove(coursToEdit.getEvent());
            int seances = model.delete(originalCours).size();
            ModalUtil.info("Sances modifies", seances + " sances ont t modifies");
            return null;
        }

    } catch (IOException e) {
        notif(e);
        return null;
    }
}

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

/**
 * Handles click events on the table. When clicking on the "image" or
 * "audio" column of a word, it opens a new stage for editing them.
 *
 * @param event/*  ww  w.  ja  va 2  s.c  o m*/
 */
private void tableClick(MouseEvent event) {
    if (!rows.isEmpty() && !tableView.getSelectionModel().getSelectedCells().isEmpty()) {
        TablePosition position = tableView.getSelectionModel().getSelectedCells().get(0);
        if (colImage.equals(position.getTableColumn())) {
            int index = position.getRow();
            RowForCard row = (RowForCard) sortedRows.get(index);
            Image currentImage = row.getImageView().getImage();
            ImagePopup imagePopup = new ImagePopup(currentImage);
            Stage stage = new Stage();
            stage.setScene(new SceneStyler().createScene(imagePopup, SceneStyler.Style.TOPIC_LIST));
            stage.setTitle(Messages.msg("form.set_image_of_word", row.getTxtWord().getText()));
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initOwner(tableView.getScene().getWindow());
            stage.setResizable(false);
            tableView.getSelectionModel().clearSelection();

            stage.showAndWait();
            if (imagePopup.isOk()) {
                Image rowImage = imagePopup.getFinalImage();
                File cardImageFile = imagePopup.getFile();
                if (rowImage != null && cardImageFile != null) {
                    row.setImageFile(cardImageFile);
                    row.setImage(rowImage);
                } else if (rowImage == null) {
                    row.setImage(DefaultImage.getInstance());
                }
            }
        } else if (colAudio.equals(position.getTableColumn())) {
            int index = position.getRow();
            RowForCard row = (RowForCard) sortedRows.get(index);
            AudioPopup audioPopup = new AudioPopup(row.getAudioIcon().getAudio());
            Stage stage = new Stage();
            stage.setScene(new SceneStyler().createScene(audioPopup, SceneStyler.Style.TOPIC_LIST));
            stage.setTitle(Messages.msg("form.set_audio_of_word", row.getTxtWord().getText()));
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.initOwner(tableView.getScene().getWindow());
            stage.setResizable(false);
            tableView.getSelectionModel().clearSelection();

            stage.showAndWait();
            if (audioPopup.isOk()) {
                File audioFile = audioPopup.getFile();
                row.setAudioFile(audioFile);
                row.setAudio(audioPopup.getFinalAudio());
            }
        }
    }
}

From source file:qupath.lib.gui.tma.TMASummaryViewer.java

public TMASummaryViewer(final Stage stage) {
    if (stage == null)
        this.stage = new Stage();
    else/*from  w  w  w .  j a v  a  2  s. c  o  m*/
        this.stage = stage;

    combinedPredicate = Bindings.createObjectBinding(() -> {
        Predicate<TMAEntry> thisPredicate = predicateHideMissing.getValue();
        if (predicateMeasurements.get() != null)
            thisPredicate = thisPredicate.and(predicateMeasurements.getValue());
        if (predicateMetadataFilter.get() != null)
            thisPredicate = thisPredicate.and(predicateMetadataFilter.getValue());
        return thisPredicate;
    }, predicateMeasurements, predicateHideMissing, predicateMetadataFilter);

    initialize();
    this.stage.setTitle("TMA Results Viewer");
    this.stage.setScene(scene);
    new DragDropTMADataImportListener(this);
}

From source file:spdxedit.PackageEditor.java

/**
 * Opens the modal package editor for the provided package.
 *
 * @param pkg               The package to edit.
 * @param relatablePackages Packages to which the edited package may optionally have defined relationships
 * @param parentWindow      The parent window.
 *///from   w  w w . ja v  a2  s.  co m
public static void editPackage(final SpdxPackage pkg, final List<SpdxPackage> relatablePackages,
        SpdxDocumentContainer documentContainer, Window parentWindow) {

    final PackageEditor packageEditor = new PackageEditor(pkg, relatablePackages, documentContainer);
    final Stage dialogStage = new Stage();
    dialogStage.setTitle("Edit SPDX Package: " + pkg.getName());
    dialogStage.initStyle(StageStyle.DECORATED);
    dialogStage.initModality(Modality.APPLICATION_MODAL);
    dialogStage.setY(parentWindow.getX() + parentWindow.getWidth() / 2);
    dialogStage.setY(parentWindow.getY() + parentWindow.getHeight() / 2);
    dialogStage.setResizable(false);
    try {
        FXMLLoader loader = new FXMLLoader(NewPackageDialog.class.getResource("/PackageEditor.fxml"));
        loader.setController(packageEditor);
        Pane pane = loader.load();
        Scene scene = new Scene(pane);
        dialogStage.setScene(scene);
        dialogStage.getIcons().clear();
        dialogStage.getIcons().add(UiUtils.ICON_IMAGE_VIEW.getImage());
        //Populate the file list on appearance
        dialogStage.setOnShown(event -> {
            try {
                final SpdxFile dummyfile = new SpdxFile(pkg.getName(), null, null, null, null, null, null, null,
                        null, null, null, null, null);
                TreeItem<SpdxFile> root = new TreeItem<>(dummyfile);
                packageEditor.filesTable.setRoot(root);
                //Assume a package without is external
                //TODO: replace with external packages or whatever alternate mechanism in 2.1
                packageEditor.btnAddFile.setDisable(pkg.getFiles().length == 0);
                root.getChildren()
                        .setAll(Stream.of(pkg.getFiles())
                                .sorted(Comparator.comparing(file -> StringUtils.lowerCase(file.getName()))) //Sort by file name
                                .map(TreeItem<SpdxFile>::new).collect(Collectors.toList()));
            } catch (InvalidSPDXAnalysisException e) {
                logger.error("Unable to get files for package " + pkg.getName(), e);
            }

            packageEditor.tabFiles.setExpanded(true);

        });

        //Won't assign this event through FXML - don't want to propagate the stage beyond this point.
        packageEditor.btnOk.setOnMouseClicked(event -> dialogStage.close());
        dialogStage.showAndWait();

    } catch (IOException ioe) {
        throw new RuntimeException("Unable to load dialog", ioe);
    }
}

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);/* w  ww.ja  v a 2  s. 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:org.mskcc.shenkers.view.IntervalViewNGTest.java

public void testStackIntervalView() throws InterruptedException {
    System.out.println("testStackIntervalView");
    int[][] d = new int[][] { { 2, 6 }, { 7, 10 }, { 1, 3 }, { 4, 6 }, { 8, 10 }, { 1, 2 }, { 3, 7 }, { 9, 10 },
            { 1, 2 }, { 3, 5 }, { 6, 7 }, { 8, 10 }, { 2, 5 }, { 8, 10 } };
    List<int[]> asList = Arrays.asList(d);
    Collections.sort(asList, new Comparator<int[]>() {

        @Override//from  w w w  .  j a  va 2 s .co  m
        public int compare(int[] o1, int[] o2) {
            return o1[0] - o2[0];
        }
    });
    List<TreeRangeSet<Integer>> rows = new ArrayList<>();
    rows.add(TreeRangeSet.create());
    for (int[] r : d) {
        Range<Integer> R = Range.closed(r[0], r[1]);
        int i = 0;
        added: {
            while (i < rows.size()) {
                TreeRangeSet<Integer> set = rows.get(i);
                RangeSet<Integer> intersection = set.subRangeSet(Range.closed(r[0] - 1, r[1] + 1));
                if (intersection.isEmpty()) {
                    set.add(R);
                    break added;
                }
                i++;
            }
            //                Stri i = ;
            TreeRangeSet<Integer> row = TreeRangeSet.create();
            row.add(R);
            rows.add(row);
        }
    }
    TilePane p = new TilePane();
    p.setSnapToPixel(false);
    for (int i = 0; i < rows.size(); i++) {
        p.getChildren().add(get(rows.get(i), 0, 11));
        System.out.println(rows.get(i).toString());
        StringBuilder sb = new StringBuilder(11);
        sb.append(StringUtils.repeat(".", 11));
        for (int j = 0; j < 11; j++) {
            if (rows.get(i).contains(j)) {
                sb.setCharAt(j, 'X');
            }
        }
        System.out.println(sb.toString());
    }
    //        p.prefWidth(100);
    //        p.prefHeight(100);
    ScrollPane sp = new ScrollPane(p);
    ScrollBar sb = new ScrollBar();
    sb.maxProperty().bind(sp.vmaxProperty());
    sb.minProperty().bind(sp.vminProperty());
    sb.visibleAmountProperty().bind(sp.heightProperty().divide(p.prefHeightProperty()));
    sb.setOrientation(Orientation.VERTICAL);
    sp.vvalueProperty().bindBidirectional(sb.valueProperty());
    HiddenSidesPane hsp = new HiddenSidesPane();
    hsp.setContent(sp);
    hsp.setRight(sb);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    sp.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    p.setOrientation(Orientation.VERTICAL);
    p.prefTileHeightProperty().bind(new SimpleDoubleProperty(40));
    //        p.minHeightProperty().bind(new SimpleDoubleProperty(20).multiply(Bindings.size(p.getChildren())));
    p.prefTileWidthProperty().bind(sp.widthProperty());
    p.prefHeightProperty()
            .bind(new SimpleDoubleProperty(50).multiply(Bindings.size(p.getChildren())).subtract(10));
    p.prefWidthProperty().bind(sp.widthProperty());
    sp.setPadding(Insets.EMPTY);
    p.setVgap(10);

    CountDownLatch l = new CountDownLatch(1);
    Platform.runLater(() -> {

        Stage stage = new Stage();
        stage.setOnHidden(e -> {
            l.countDown();
        });
        Scene scene = new Scene(hsp, 300, 300, Color.GRAY);
        stage.setTitle("JavaFX Scene Graph Demo");
        stage.setScene(scene);
        stage.show();

    });
    l.await();
}