List of usage examples for javafx.stage Stage initModality
public final void initModality(Modality modality)
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
private void showAlert(String text) { Stage dialogStage = new Stage(); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.setScene(new Scene(VBoxBuilder.create().children(new Text(text), new Button("Ok")) .alignment(Pos.CENTER).padding(new Insets(5)).build())); dialogStage.show();//from www . j av a2 s. c o m }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void handleMenuSettingsPreferences(ActionEvent event) throws Exception { Stage preferencesStage = new Stage(); preferencesStage.initModality(Modality.WINDOW_MODAL); FXMLLoader fxmlLoader = new FXMLLoader(); Parent root = (Parent) fxmlLoader.load(getClass().getResource("preferences.fxml").openStream()); PreferencesController controller = fxmlLoader.getController(); controller.setPrimaryStage(preferencesStage); controller.setPrimaryController(this); preferencesStage.setTitle("Talismane Terminology Viewer Preferences"); preferencesStage.setScene(new Scene(root, 400, 300)); preferencesStage.show();/*from w w w . j a v a 2s.co m*/ }
From source file:jp.ac.tohoku.ecei.sb.metabolome.lims.gui.MainWindowController.java
@Override public void initialize(URL location, ResourceBundle resources) { // Table Study initializeTable(tableStudy, StudyImpl.class); initializeTable(tablePlate, PlateImpl.class); initializeTable(tableSample, SampleImpl.class); initializeTable(tableInjection, InjectionImpl.class); initializeTable(tableCompound, CompoundImpl.class); initializeTable(tableHistory, OperationHistoryImpl.class); menuBar.setUseSystemMenuBar(true);//ww w . j a v a2s. c o m commandManager = new CommandManager(); commandManager.setContext(commandManagerContext); final GUICommandPaneFactory commandPaneFactory = new GUICommandPaneFactory(commandManager); MetabolomeQC.addCorrectionCommands(commandManager); for (Map.Entry<String, Class> commend : commandManager.getCommands().entrySet()) { MenuItem menuItem = new MenuItem(commend.getKey()); menuItem.setText(commend.getKey()); menuItem.setOnAction(e -> { final Stage stage = new Stage(); stage.initModality(Modality.WINDOW_MODAL); Parent guiCommand = commandPaneFactory.getCommandPane(commend.getKey(), (commandEvent, managedCommand) -> { stage.close(); }); BorderPane margins = new BorderPane(guiCommand); BorderPane.setMargin(guiCommand, new Insets(10)); stage.setScene(new Scene(margins)); stage.initOwner(this.stage); stage.showAndWait(); onRefresh(null); }); correctionMenu.getItems().add(menuItem); } onRefresh(null); }
From source file:tachyon.view.ProjectProperties.java
public ProjectProperties(JavaProject project, Window w) { this.project = project; stage = new Stage(); stage.initOwner(w);/* w ww .j av a 2 s .c o m*/ 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:de.micromata.mgc.javafx.ControllerService.java
public <M, C extends AbstractModelController<M>> C loadAsDialog(AbstractMainWindow<?> mainWindow, Class<C> controllerClass, String dialogTitle) { Pair<Pane, C> pair = loadControllerControl(controllerClass, Pane.class, mainWindow); Stage stage = new Stage(); stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, e -> { stage.hide();// w w w .j av a2 s. c om e.consume(); }); Pane root = pair.getFirst(); C controller = pair.getSecond(); Scene s = new Scene(root);//, AbstractConfigDialog.PREF_WIDTH, AbstractConfigDialog.PREF_HEIGHT controller.setParent(root); controller.setScene(s); controller.setStage(stage); stage.setScene(s); stage.initModality(Modality.APPLICATION_MODAL); //stage.setResizable(false); stage.setTitle(dialogTitle); return controller; }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Shows the confirmation dialog// w w w. j a v a 2s . c o m */ private boolean showConfirmationDialog(String msg) { try { // Load the fxml file and create a new stage for the popup FXMLLoader loader = new FXMLLoader(getClass().getResource("ConfirmationDialog.fxml")); Parent page = (Parent) loader.load(); Stage dialogStage = new Stage(); dialogStage.setTitle(UIMessages.getMessage("UI_CLOSE_TAB_TITLE")); dialogStage.initModality(Modality.APPLICATION_MODAL); dialogStage.initOwner(stage); Scene scene = new Scene(page); dialogStage.setScene(scene); // Set the person into the controller ConfirmationDialogController controller = loader.getController(); controller.setDialogStage(dialogStage); controller.setConfirmationMsg(msg); // Show the dialog and wait until the user closes it dialogStage.showAndWait(); return controller.isOkClicked(); } catch (IOException e) { e.printStackTrace(); } return false; }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Perform functionality associated with "About" menu selection or CTRL-A. *//*from w w w. ja v a 2 s . co m*/ private void showLoggerDialog() { try { // Load the fxml file and create a new stage for the popup FXMLLoader loader = new FXMLLoader(getClass().getResource("LoggerDialog.fxml")); Parent page = (Parent) loader.load(); Stage dialogStage = new Stage(); dialogStage.setTitle(UIMessages.getMessage("UI_LOGGER_BOX_LABEL")); dialogStage.initModality(Modality.NONE); dialogStage.initOwner(stage); Scene scene = new Scene(page); dialogStage.setScene(scene); // Set the person into the controller LoggerDialogController controller = loader.getController(); controller.setDialogStage(dialogStage); controller.setOutputBuffer(outputBuffer.toString()); controller.onClearLoggerEvent(() -> outputBuffer = new StringBuffer()); // Show the dialog dialogStage.show(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Shows the report options dialog/*from w w w .j av a2 s . c om*/ */ private void showReportOptionsDialog() { try { // Load the fxml file and create a new stage for the popup FXMLLoader loader = new FXMLLoader(getClass().getResource("ReportOptions.fxml")); AnchorPane page = (AnchorPane) loader.load(); Stage dialogStage = new Stage(); dialogStage.setTitle(UIMessages.getMessage("UI_REPORT_OPTIONS_TITLE")); dialogStage.initModality(Modality.APPLICATION_MODAL); dialogStage.initOwner(stage); Scene scene = new Scene(page); dialogStage.setScene(scene); // Set the person into the controller ReportOptionsController controller = loader.getController(); controller.setDialogStage(dialogStage); controller.setReport(this.fixtures.getReport()); //TODO: we need to clone our Report Object Here // Show the dialog and wait until the user closes it dialogStage.showAndWait(); if (controller.isOkClicked()) { this.fixtures.setReport(controller.getReport()); } } catch (IOException e) { e.printStackTrace(); } }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Perform functionality associated with "About" menu selection or CTRL-A. *//*from w w w . j a v a 2 s. co m*/ private void provideAboutFunctionality() { try { // Load the fxml file and create a new stage for the popup FXMLLoader loader = new FXMLLoader(getClass().getResource("AboutDialog.fxml")); Parent page = (Parent) loader.load(); Stage dialogStage = new Stage(); dialogStage.setTitle(UIMessages.getMessage("UI_HELP_ABOUT_MENU_ITEM_LABEL")); dialogStage.initModality(Modality.APPLICATION_MODAL); dialogStage.initOwner(stage); Scene scene = new Scene(page); dialogStage.setScene(scene); // Set the person into the controller AboutDialogController controller = loader.getController(); controller.setDialogStage(dialogStage); // Show the dialog and wait until the user closes it dialogStage.showAndWait(); } catch (IOException e) { e.printStackTrace(); } }
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);/* w w w . java 2 s.co m*/ stage.initModality(Modality.APPLICATION_MODAL); stage.setScene(new Scene(aboutView.getView())); stage.setTitle("About"); stage.show(); }