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:main.Content.java

public boolean showInputDialog(Activity aktivitet) {
    try {//w w  w  .j av a2  s  .c o  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: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 {//from  www .j ava 2 s.  co  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:org.ado.musicdroid.view.AppPresenter.java

public void about() {
    final 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:Main.java

private void createClipList(GridPane grid) {
    final VBox vbox = new VBox(30);
    vbox.setAlignment(Pos.TOP_CENTER);/*from  w  w  w .  ja v a 2 s . c  o  m*/

    final Label clipLabel = new Label("Code Monkey To-Do List:");
    clipLabel.setId("clipLabel");

    final Button getUpButton = new Button("Get Up, Get Coffee");
    getUpButton.setPrefWidth(300);
    getUpButton.setOnAction(createPlayHandler(coffeeClip));

    final Button goToJobButton = new Button("Go to Job");
    goToJobButton.setPrefWidth(300);
    goToJobButton.setOnAction(createPlayHandler(jobClip));

    final Button meetingButton = new Button("Have Boring Meeting");
    meetingButton.setPrefWidth(300);
    meetingButton.setOnAction(createPlayHandler(meetingClip));

    final Hyperlink link = new Hyperlink("About Code Monkey...");
    link.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            WebView wv = new WebView();
            wv.getEngine().load("http://www.jonathancoulton.com/2006/04/14/" + "thing-a-week-29-code-monkey/");

            Scene scene = new Scene(wv, 720, 480);

            Stage stage = new Stage();
            stage.setTitle("Code Monkey");
            stage.setScene(scene);
            stage.show();
        }
    });

    vbox.getChildren().addAll(clipLabel, getUpButton, goToJobButton, meetingButton, link);

    GridPane.setHalignment(vbox, HPos.CENTER);
    GridPane.setHgrow(vbox, Priority.ALWAYS);
    GridPane.setVgrow(vbox, Priority.ALWAYS);
    grid.add(vbox, 0, 0, GridPane.REMAINING, 1);
}

From source file:dbsdemo.RegistrationWindowController.java

public void goToMainWindowScene(User user) {
    // Load properties file - TODO catch exception
    Properties prop = PropLoader.load("etc/config.properties");
    // Continue to main window screen
    try {/*  ww w  .ja v a 2 s .co m*/
        FXMLLoader loader = new FXMLLoader(getClass().getResource(prop.getProperty("MainWindowPath")));
        Parent root = (Parent) loader.load();

        MainWindowController mainWindowController = loader.getController();
        mainWindowController.setActiveUser(user);

        //Scene scene = new Scene(root);
        Stage mainWindowStage = new Stage();
        mainWindowStage.setTitle("Fuel database");
        mainWindowStage.setMinHeight(mainWindowStage.getHeight());
        mainWindowStage.setMinWidth(mainWindowStage.getWidth());
        mainWindowStage.setScene(new Scene(root));

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

From source file:fruitproject.FruitProject.java

public void second(final String pfname) {

    final Stage st = new Stage();
    Scene scene = null;//from   w w  w. j a v a 2  s . c  o  m
    final GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));
    TableView tv = new TableView();

    final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name");
    final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount");
    final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove");
    firstDataColumn.setMinWidth(130);
    secondDataColumn.setMinWidth(130);
    thirdDataColumn.setMinWidth(130);

    if (!pfname.equals("")) {

        firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey));
        secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey));
        thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey));

        rows = 0;
        tv = new TableView<>(generateDataInMap(pfname, addPairs));

    }

    tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn);

    // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn());

    ScrollPane sp = new ScrollPane();
    sp.setMinWidth(400);
    sp.setHbarPolicy(ScrollBarPolicy.NEVER);
    sp.setContent(tv);
    grid.add(sp, 0, 3);

    final ComboBox comboBox = new ComboBox();
    HBox hb1 = new HBox();
    comboBox.setValue("FILE");
    comboBox.getItems().addAll("Save this file", "Load a new file");
    Button btnOk = new Button();
    btnOk.setText("OK");
    hb1.getChildren().addAll(comboBox, btnOk);
    hb1.setSpacing(10);
    grid.add(hb1, 0, 1);

    Label label1 = new Label("Title:");
    final TextField tfFilename = new TextField();
    tfFilename.setText(getTitle(pfname));
    HBox hb = new HBox();
    hb.getChildren().addAll(label1, tfFilename);
    hb.setSpacing(10);
    grid.add(hb, 0, 2);

    final Stage ps = new Stage();
    final TableView tv1 = tv;
    btnOk.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            //System.out.println("Hello World!");

            if (comboBox.getValue().equals("Load a new file")) {
                first(ps);
                st.close();
            } else {
                PrintWriter pw = null;
                try {
                    pw = new PrintWriter("abc.json");
                    BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false));
                    bw.write("{title:\"" + tfFilename.getText() + "\"");
                    bw.write(",fruits:[");
                    for (int i = 0; i < rows; i++) {
                        bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:"
                                + String.valueOf(secondDataColumn.getCellData(i)) + "}");
                        if (i != rows - 1)
                            bw.write(",");
                    }
                    bw.write("]}");

                    bw.close();

                } catch (Exception e) {
                    System.out.println(e.toString());
                }

            }
        }
    });

    Button btn = new Button();
    btn.setText("New Fruit");
    grid.add(btn, 1, 2);

    // TableView tv=new TableView();
    // TableColumn Col1 = new TableColumn("Name");
    // TableColumn Col2 = new TableColumn("Amount");
    // TableColumn Col3 = new TableColumn("Remove");
    // tv.getColumns().addAll(Col1, Col2, Col3);

    //sp.setFitToWidth(true);

    Image img = new Image("file:music.jpg");
    ImageView iv2 = new ImageView();
    iv2.setImage(img);
    iv2.setFitWidth(200);
    iv2.setPreserveRatio(true);
    iv2.setSmooth(true);
    iv2.setCache(true);
    grid.add(iv2, 1, 3);

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

        @Override
        public void handle(ActionEvent event) {
            //System.out.println("Hello World!");

            System.out.println(comboBox.valueProperty());
            st.close();
            third(pfname);

        }
    });

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

}

From source file:com.panemu.tiwulfx.control.LookupFieldController.java

/**
 * Show lookup dialog.//from ww  w .ja  v a  2  s.co  m
 *
 * @param stage parent
 * @param initialValue this value will be returned if user clik the close
 * button instead of double clicking a row or click Select button
 * @param propertyName propertyName corresponds to searchCriteria
 * @param searchCriteria searchCriteria (nullable)
 * @return selected object or the initialValue
 */
public T show(final Window stage, T initialValue, String propertyName, String searchCriteria) {
    if (dialogStage == null) {
        PropertyDescriptor[] props = PropertyUtils.getPropertyDescriptors(recordClass);
        lookupWindow = new LookupWindow();
        for (String clm : getColumns()) {
            for (PropertyDescriptor prop : props) {
                if (prop.getName().equals(clm)) {
                    Class type = prop.getPropertyType();
                    if (type.equals(Boolean.class)) {
                        lookupWindow.table.addColumn(new CheckBoxColumn<T>(clm));
                    } else if (type.equals(String.class)) {
                        lookupWindow.table.addColumn(new TextColumn<T>(clm));
                    } else if (type.equals(Date.class)) {
                        lookupWindow.table.addColumn(new LocalDateColumn<T>(clm));
                    } else if (Number.class.isAssignableFrom(type)) {

                        if (Long.class.isAssignableFrom(type)) {
                            lookupWindow.table.addColumn(new NumberColumn<T, Long>(clm, type));
                        } else {
                            lookupWindow.table.addColumn(new NumberColumn<T, Double>(clm, type));
                        }
                    } else {
                        TableColumn column = new TableColumn();
                        column.setCellValueFactory(new PropertyValueFactory(clm));
                        lookupWindow.table.addColumn(column);
                    }
                    break;
                }
            }

        }
        dialogStage = new Stage();
        if (stage instanceof Stage) {
            dialogStage.initOwner(stage);
            dialogStage.initModality(Modality.WINDOW_MODAL);
        } else {
            dialogStage.initOwner(null);
            dialogStage.initModality(Modality.APPLICATION_MODAL);
        }
        dialogStage.initStyle(StageStyle.UTILITY);
        dialogStage.setResizable(true);
        dialogStage.setScene(new Scene(lookupWindow));
        dialogStage.getIcons().add(new Image(
                LookupFieldController.class.getResourceAsStream("/com/panemu/tiwulfx/res/image/lookup.png")));
        dialogStage.setTitle(getWindowTitle());
        dialogStage.getScene().getStylesheets()
                .add(getClass().getResource("/com/panemu/tiwulfx/res/tiwulfx.css").toExternalForm());
        initCallback(lookupWindow, lookupWindow.table);
    }

    for (TableColumn column : lookupWindow.table.getTableView().getColumns()) {
        if (column instanceof BaseColumn && ((BaseColumn) column).getPropertyName().equals(propertyName)) {
            if (searchCriteria != null && !searchCriteria.isEmpty()) {
                TableCriteria tc = new TableCriteria(propertyName, TableCriteria.Operator.ilike_anywhere,
                        searchCriteria);
                ((BaseColumn) column).setTableCriteria(tc);
            } else {
                ((BaseColumn) column).setTableCriteria(null);
            }

            break;
        }
    }
    selectedValue = initialValue;
    beforeShowCallback(lookupWindow.table);
    lookupWindow.table.reloadFirstPage();

    if (stage != null) {
        /**
         * Since we support multiple monitors, ensure that the stage is
         * located in the center of parent stage. But we don't know the
         * dimension of the stage for the calculation, so we defer the
         * relocation after the stage is actually displayed.
         */
        Runnable runnable = new Runnable() {
            public void run() {
                dialogStage.setX(stage.getX() + stage.getWidth() / 2 - dialogStage.getWidth() / 2);
                dialogStage.setY(stage.getY() + stage.getHeight() / 2 - dialogStage.getHeight() / 2);

                //set the opacity back to fully opaque
                dialogStage.setOpacity(1);
            }
        };

        Platform.runLater(runnable);

        //set the opacity to 0 to minimize flicker effect
        dialogStage.setOpacity(0);
    }

    dialogStage.showAndWait();
    return selectedValue;
}

From source file:qupath.lib.gui.panels.classify.RandomTrainingRegionSelector.java

private void createDialog() {
    dialog = new Stage();
    dialog.initOwner(qupath.getStage());
    dialog.setTitle("Training sample selector");

    pointCreator = new RandomPointCreator();

    for (PathClass pathClass : pathClassListModel) {
        if (pathClass != null && pathClass.getName() != null)
            pointCreator.addPathClass(pathClass,
                    KeyCode.getKeyCode(pathClass.getName().toUpperCase().substring(0, 1)));
        //            pointCreator.addPathClass(pathClass, KeyStroke.getKeyStroke(new pathClass.getName().toLowerCase().charAt(0), 0).getKeyCode());
    }// ww w. j a v a 2s  .co  m
    //      PathClass tumourClass = PathClassFactory.getDefaultPathClass(PathClasses.TUMOR);
    //      PathClass stromaClass = PathClassFactory.getDefaultPathClass(PathClasses.STROMA);
    //      pointCreator.addPathClass(tumourClass, KeyCode.T);
    //      pointCreator.addPathClass(stromaClass, KeyCode.S);
    QuPathViewer viewer = qupath.getViewer();
    pointCreator.registerViewer(viewer);

    // Adapt to changing active viewers
    ImageDataChangeListener<BufferedImage> listener = new ImageDataChangeListener<BufferedImage>() {

        @Override
        public void imageDataChanged(ImageDataWrapper<BufferedImage> source,
                ImageData<BufferedImage> imageDataOld, ImageData<BufferedImage> imageDataNew) {
            if (pointCreator != null) {
                QuPathViewer viewer = qupath.getViewer();
                pointCreator.registerViewer(viewer);
                updateObjectCache(viewer);
            }
            refreshList();
            updateLabel();
        }

    };
    qupath.addImageDataChangeListener(listener);

    // Remove listeners for cleanup
    dialog.setOnCloseRequest(e -> {
        pointCreator.deregisterViewer();
        qupath.removeImageDataChangeListener(listener);
        dialog.setOnCloseRequest(null);
        dialog = null;
        // Re-enable mode switching
        qupath.setModeSwitchingEnabled(true);
    });

    ParameterPanelFX paramPanel = new ParameterPanelFX(params);
    paramPanel.getPane().setPadding(new Insets(2, 5, 5, 5));

    list = new ListView<PathClass>(pathClassListModel);
    list.setPrefSize(400, 200);

    // TODO: ADD A SENSIBLE RENDERER!
    // For now, this is simply duplicated from PathAnnotationPanel
    list.setCellFactory(new Callback<ListView<PathClass>, ListCell<PathClass>>() {

        @Override
        public ListCell<PathClass> call(ListView<PathClass> p) {

            ListCell<PathClass> cell = new ListCell<PathClass>() {

                @Override
                protected void updateItem(PathClass value, boolean bln) {
                    super.updateItem(value, bln);
                    int size = 10;
                    if (value == null) {
                        setText(null);
                        setGraphic(null);
                    } else if (value.getName() == null) {
                        setText("None");
                        setGraphic(new Rectangle(size, size, ColorToolsFX.getCachedColor(0, 0, 0, 0)));
                    } else {
                        setText(value.getName());
                        setGraphic(new Rectangle(size, size, ColorToolsFX.getPathClassColor(value)));
                    }
                }

            };

            return cell;
        }
    });

    //      list.setCellRenderer(new PathClassListCellRendererPoints());

    list.setTooltip(new Tooltip("Available classes"));

    labelCount = new Label();
    labelCount.setTextAlignment(TextAlignment.CENTER);
    labelCount.setPadding(new Insets(5, 0, 5, 0));
    BorderPane panelTop = new BorderPane();
    panelTop.setTop(paramPanel.getPane());
    panelTop.setCenter(list);
    panelTop.setBottom(labelCount);
    labelCount.prefWidthProperty().bind(panelTop.widthProperty());
    updateLabel();

    //      panelButtons.add(new JButton(new UndoAction("Undo")));
    Action actionAdd = new Action("Add to class", e -> {
        if (list == null || pointCreator == null)
            return;
        PathClass pathClass = list.getSelectionModel().getSelectedItem();
        pointCreator.addPoint(pathClass);
    });
    Action actionSkip = new Action("Skip", e -> {
        if (pointCreator != null)
            pointCreator.addPoint(null);
    });

    GridPane panelButtons = PanelToolsFX.createColumnGridControls(ActionUtils.createButton(actionAdd),
            ActionUtils.createButton(actionSkip));

    BorderPane pane = new BorderPane();
    pane.setCenter(panelTop);
    pane.setBottom(panelButtons);

    pane.setPadding(new Insets(10, 10, 10, 10));
    Scene scene = new Scene(pane);
    dialog.setScene(scene);
}

From source file:UI.MainPageController.java

/**
 * Popup dialog box that display the string passed in
 * @param warning /*from  w  ww .  ja v  a2  s .  co  m*/
 */
private void showWarning(String warning) {
    Stage popup = new Stage();
    VBox headsUp = new VBox();
    Text prompt = new Text(warning);
    prompt.setStyle("-fx-font-size: 11pt;");
    headsUp.getChildren().add(prompt);
    headsUp.setAlignment(Pos.CENTER);
    popup.setScene(new Scene(headsUp, 300, 200));
    popup.setTitle("Warning");
    popup.show();
}

From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java

@FXML
void onOpen(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open Metabolome Analysis File");
    fileChooser.getExtensionFilters()/*  ww  w .ja va  2  s  .c  o  m*/
            .addAll(new FileChooser.ExtensionFilter("Supported Files", Arrays.asList("*.zip", "*.csv")));
    File file = fileChooser.showOpenDialog(stage);
    if (file == null)
        return;
    if (!opened) {
        openData(file);
    } else {
        try {
            Stage primaryStage = new Stage();
            FXMLLoader loader = new FXMLLoader(getClass().getResource("mainwindow.fxml"));
            loader.load();
            MainWindowController controller = loader.getController();
            controller.setStage(primaryStage);
            VBox root = loader.getRoot();
            Scene scene = new Scene(root);
            primaryStage.setScene(scene);
            controller.openData(file);
            primaryStage.show();
        } catch (IOException e) {
            e.printStackTrace();
            AlertHelper.showExceptionAlert("Cannot open", null, e);
        }
    }
}