Java Code Examples for javafx.stage.Stage#initModality()
The following examples show how to use
javafx.stage.Stage#initModality() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIController.java From dctb-utfpr-2018-1 with Apache License 2.0 | 6 votes |
public void startApp(Stage stage) { mainStage = stage; modalStage = new Stage(); modalStage.initOwner(mainStage); modalStage.initModality(Modality.APPLICATION_MODAL); mainStage.setMinWidth(1280); mainStage.setMinHeight(720); try { indexParent = FXMLLoader.load(getClass().getResource("register/CustomerRegister.fxml")); } catch (IOException ex) { Logger.getLogger(GUIController.class.getName()).log(Level.SEVERE, null, ex); } nowScene = new Scene(indexParent); executionStack.push(nowScene); mainStage.setScene(nowScene); mainStage.show(); }
Example 2
Source File: MainProgramSceneController.java From Hostel-Management-System with MIT License | 6 votes |
@FXML private void changePasswordAction(ActionEvent event) { mainTopAnchorPane.setEffect(new BoxBlur()); passwordStage = new Stage(); passwordStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { mainTopAnchorPane.effectProperty().setValue(null); } }); passwordStage.setTitle("Change Password"); passwordStage.initModality(Modality.APPLICATION_MODAL); passwordStage.initStyle(StageStyle.UTILITY); passwordStage.setResizable(false); try { Parent passwordParent = FXMLLoader.load(getClass().getResource("changepassword.fxml")); passwordStage.setScene(new Scene(passwordParent)); passwordStage.show(); } catch (IOException ex) { } }
Example 3
Source File: EventLogController.java From pmd-designer with BSD 2-Clause "Simplified" License | 6 votes |
private Stage createStage(Stage mainStage) { FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("event-log")); loader.setController(this); final Stage dialog = new Stage(); dialog.initOwner(mainStage.getScene().getWindow()); dialog.initModality(Modality.NONE); Parent root; try { root = loader.load(); } catch (IOException e) { throw new IllegalStateException(e); } Scene scene = new Scene(root); dialog.setScene(scene); return dialog; }
Example 4
Source File: BetonQuestEditor.java From BetonQuest-Editor with GNU General Public License v3.0 | 6 votes |
/** * Creates a pop-up window with specified parameters and returns the controller object. * * @param fxml path of the FXML resource file * @param title ID of translated window title message * @param width width of the window * @param height height of the window * @return the controller oject for this window */ public static Object createWindow(String fxml, String title, int width, int height) { try { Stage window = new Stage(); URL location = BetonQuestEditor.class.getResource(fxml); ResourceBundle resources = ResourceBundle.getBundle("pl.betoncraft.betonquest.editor.resource.lang.lang", Persistence.getSettings().getLanguage()); FXMLLoader fxmlLoader = new FXMLLoader(location, resources); Parent root = (Parent) fxmlLoader.load(); Scene scene = new Scene(root); scene.getStylesheets().add(BetonQuestEditor.class.getResource("resource/style.css").toExternalForm()); window.setScene(scene); window.setTitle(resources.getString(title)); window.getIcons().add(new Image(BetonQuestEditor.class.getResourceAsStream("resource/icon.png"))); window.setHeight(height); window.setWidth(width); window.setResizable(false); window.initModality(Modality.WINDOW_MODAL); window.initOwner(instance.stage); return fxmlLoader.getController(); } catch (IOException e) { ExceptionController.display(e); return null; } }
Example 5
Source File: FxmlStage.java From MyBox with Apache License 2.0 | 6 votes |
public static BaseController openStage(Stage myStage, String newFxml, boolean isOwned, Modality modality, StageStyle stageStyle) { try { Stage stage = new Stage(); stage.initModality(modality); if (isOwned && myStage != null) { stage.initOwner(myStage); } else { stage.initOwner(null); } return initScene(stage, newFxml, stageStyle); } catch (Exception e) { logger.error(e.toString()); return null; } }
Example 6
Source File: Main.java From VickyWarAnalyzer with MIT License | 6 votes |
private static void showErrorDialog(Throwable e) { StringWriter errorMsg = new StringWriter(); e.getCause().getCause().printStackTrace(new PrintWriter(errorMsg)); Stage dialog = new Stage(); dialog.initModality(Modality.APPLICATION_MODAL); FXMLLoader loader = new FXMLLoader(Main.class.getClassLoader() .getResource("Error.fxml")); try { Parent root = loader.load(); ((ErrorController) loader.getController()).setErrorText(errorMsg .toString()); dialog.setScene(new Scene(root, 250, 400)); dialog.show(); } catch (IOException exc) { exc.printStackTrace(); } }
Example 7
Source File: HideTaskBar.java From oim-fx with MIT License | 6 votes |
@Override public void start(final Stage stage) throws Exception { stage.initStyle(StageStyle.UTILITY); stage.setScene(new Scene(new Group(), 100, 100)); stage.setX(0); stage.setY(Screen.getPrimary().getBounds().getHeight() + 100); stage.show(); Stage app = new Stage(); app.setScene(new Scene(new Group(), 300, 200)); app.setTitle("JavaFX隐藏任务栏"); app.initOwner(stage); app.initModality(Modality.APPLICATION_MODAL); app.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { event.consume(); stage.close(); } }); app.show(); }
Example 8
Source File: NaviSelectDemo.java From tornadofx-controls with Apache License 2.0 | 6 votes |
/** * Select value example. Implement whatever technique you want to change value of the NaviSelect */ private void selectEmail(NaviSelect<Email> navi) { Stage dialog = new Stage(StageStyle.UTILITY); dialog.setTitle("Choose person"); ListView<Email> listview = new ListView<>(FXCollections.observableArrayList( new Email("[email protected]", "John Doe"), new Email("[email protected]", "Jane Doe"), new Email("[email protected]", "Some Dude") )); listview.setOnMouseClicked(event -> { Email item = listview.getSelectionModel().getSelectedItem(); if (item != null) { navi.setValue(item); dialog.close(); } }); dialog.setScene(new Scene(listview)); dialog.setWidth(navi.getWidth()); dialog.initModality(Modality.APPLICATION_MODAL); dialog.setHeight(100); dialog.showAndWait(); }
Example 9
Source File: DesignerApplication.java From OEE-Designer with MIT License | 6 votes |
DatabaseEventSource showDatabaseServerEditor() throws Exception { FXMLLoader loader = FXMLLoaderFactory.databaseServerLoader(); AnchorPane page = (AnchorPane) loader.getRoot(); // Create the dialog Stage. Stage dialogStage = new Stage(StageStyle.DECORATED); dialogStage.setTitle(DesignerLocalizer.instance().getLangString("db.editor.title")); dialogStage.initModality(Modality.WINDOW_MODAL); Scene scene = new Scene(page); dialogStage.setScene(scene); // get the controller DatabaseServerController databaseServerController = loader.getController(); databaseServerController.setDialogStage(dialogStage); databaseServerController.initialize(this); // Show the dialog and wait until the user closes it if (!databaseServerController.getDialogStage().isShowing()) { databaseServerController.getDialogStage().showAndWait(); } return databaseServerController.getSource(); }
Example 10
Source File: Dialog.java From HubTurbo with GNU Lesser General Public License v3.0 | 5 votes |
public Dialog(Stage parentStage) { this.response = new CompletableFuture<>(); // TODO Calling an overridable method during construction should be // fixed via an API change Scene scene = new Scene(content(), width, height); // NOPMD stage = new Stage(); stage.setScene(scene); stage.setTitle(title); stage.setOnCloseRequest(this::onClose); stage.initOwner(parentStage); Modality modality = Modality.APPLICATION_MODAL; stage.initModality(modality); stage.initStyle(stageStyle); }
Example 11
Source File: HashPanel.java From MythRedisClient with Apache License 2.0 | 5 votes |
/** * 显示连接属性面板. * @param isHash 是否为hash * @param key 键 * @return 是否点击确认 */ public boolean showPanel(boolean isHash, String key) { boolean ok = false; // 创建 FXMLLoader 对象 FXMLLoader loader = new FXMLLoader(); // 加载文件 loader.setLocation(this.getClass().getResource("/views/HashAddLayout.fxml")); AnchorPane pane = null; try { pane = loader.load(); } catch (IOException e) { e.printStackTrace(); } // 创建对话框 Stage dialogStage = new Stage(); dialogStage.setTitle("添加键值对"); dialogStage.initModality(Modality.WINDOW_MODAL); Scene scene = new Scene(pane); dialogStage.setScene(scene); hashAddController = loader.getController(); hashAddController.setDialogStage(dialogStage); isAddHash(isHash); setHashKey(key); // 显示对话框, 并等待, 直到用户关闭 dialogStage.showAndWait(); ok = hashAddController.isOkChecked(); return ok; }
Example 12
Source File: ChromatogramPlotWindowController.java From old-mzmine3 with GNU General Public License v2.0 | 5 votes |
public void handleSetupLayers(Event e) { try { URL layersDialogFXML = getClass().getResource(LAYERS_DIALOG_FXML); FXMLLoader loader = new FXMLLoader(layersDialogFXML); Stage layersDialog = loader.load(); ChromatogramLayersDialogController controller = loader.getController(); controller.configure(datasets, this); layersDialog.initModality(Modality.APPLICATION_MODAL); layersDialog.show(); } catch (Exception ex) { ex.printStackTrace(); } }
Example 13
Source File: DesignerApplication.java From OEE-Designer with MIT License | 5 votes |
void showDatabaseTrendDialog(EventResolver eventResolver) throws Exception { // Load the fxml file and create a new stage for the pop-up dialog. FXMLLoader loader = FXMLLoaderFactory.databaseTrendLoader(); AnchorPane page = (AnchorPane) loader.getRoot(); // Create the dialog Stage. Stage dialogStage = new Stage(StageStyle.DECORATED); dialogStage.setTitle(DesignerLocalizer.instance().getLangString("db.event.trend")); dialogStage.initModality(Modality.NONE); Scene scene = new Scene(page); dialogStage.setScene(scene); // get the controller DatabaseTrendController databaseTrendController = loader.getController(); databaseTrendController.setDialogStage(dialogStage); databaseTrendController.setApp(this); // add the trend chart SplitPane chartPane = databaseTrendController.initializeTrend(); AnchorPane.setBottomAnchor(chartPane, 50.0); AnchorPane.setLeftAnchor(chartPane, 5.0); AnchorPane.setRightAnchor(chartPane, 5.0); AnchorPane.setTopAnchor(chartPane, 50.0); page.getChildren().add(0, chartPane); // set the script resolver databaseTrendController.setEventResolver(eventResolver); // connect to the database server databaseTrendController.subscribeToDataSource(); // show the window databaseTrendController.getDialogStage().show(); }
Example 14
Source File: CurlyApp.java From curly with Apache License 2.0 | 5 votes |
public static Action editAction(Action source, Runnable persistHandler) { final BooleanProperty okPressed = new SimpleBooleanProperty(false); if (source == null) { source = new Action(); } try { FXMLLoader loader = new FXMLLoader(CurlyApp.class.getResource("/fxml/ActionPanel.fxml")); loader.setResources(ApplicationState.getInstance().getResourceBundle()); loader.load(); ActionPanelController actionController = loader.getController(); Stage popup = new Stage(); popup.setScene(new Scene(loader.getRoot())); popup.initModality(Modality.APPLICATION_MODAL); popup.initOwner(applicationWindow); actionController.populateValues(source, true); actionController.onPersist(() -> { if (persistHandler != null) { persistHandler.run(); } okPressed.set(true); }); actionController.whenFinished(popup::close); popup.showAndWait(); } catch (IOException ex) { Logger.getLogger(CurlyApp.class.getName()).log(Level.SEVERE, null, ex); } if (okPressed.get()) { return source; } else { return null; } }
Example 15
Source File: DesignerApplication.java From OEE-Designer with MIT License | 5 votes |
OpcUaTreeNode showOpcUaDataSourceBrowser() throws Exception { if (opcUaBrowserController == null) { // Load the fxml file and create a new stage for the pop-up dialog. FXMLLoader loader = FXMLLoaderFactory.opdUaBrowserLoader(); AnchorPane page = (AnchorPane) loader.getRoot(); // Create the dialog Stage. Stage dialogStage = new Stage(StageStyle.DECORATED); dialogStage.setTitle(DesignerLocalizer.instance().getLangString("opc.ua.title")); dialogStage.initModality(Modality.NONE); Scene scene = new Scene(page); dialogStage.setScene(scene); // get the controller opcUaBrowserController = loader.getController(); opcUaBrowserController.setDialogStage(dialogStage); opcUaBrowserController.initialize(this); } // Show the dialog and wait until the user closes it if (!opcUaBrowserController.getDialogStage().isShowing()) { opcUaBrowserController.getDialogStage().showAndWait(); } return opcUaBrowserController.getSelectedNodeId(); }
Example 16
Source File: ConnectPanel.java From MythRedisClient with Apache License 2.0 | 5 votes |
/** * 显示连接属性面板. * @return 是否点击确认 */ public boolean showConnectPanel(String poolId) { boolean ok = false; // 创建 FXMLLoader 对象 FXMLLoader loader = new FXMLLoader(); // 加载文件 loader.setLocation(this.getClass().getResource("/views/ConnectLayout.fxml")); AnchorPane pane = null; try { pane = loader.load(); } catch (IOException e) { e.printStackTrace(); } // 创建对话框 Stage dialogStage = new Stage(); dialogStage.setTitle("创建连接"); dialogStage.initModality(Modality.WINDOW_MODAL); Scene scene = new Scene(pane); dialogStage.setScene(scene); connectController = loader.getController(); connectController.setDialogStage(dialogStage); connectController.setPoolId(poolId); // 显示对话框, 并等待, 直到用户关闭 dialogStage.showAndWait(); ok = connectController.isOkChecked(); return ok; }
Example 17
Source File: UomEditorController.java From OEE-Designer with MIT License | 4 votes |
@FXML private void onImportUom() throws Exception { try { if (uomImportController == null) { FXMLLoader loader = FXMLLoaderFactory.uomImporterLoader(); AnchorPane pane = (AnchorPane) loader.getRoot(); // Create the dialog Stage. Stage dialogStage = new Stage(StageStyle.DECORATED); dialogStage.setTitle(DesignerLocalizer.instance().getLangString("import.uom.title")); dialogStage.initModality(Modality.NONE); Scene scene = new Scene(pane); dialogStage.setScene(scene); // get the controller uomImportController = loader.getController(); uomImportController.setDialogStage(dialogStage); } // Show the dialog and wait until the user closes it uomImportController.getDialogStage().showAndWait(); if (uomImportController.isCancelled()) { return; } UnitOfMeasure uom = uomImportController.getSelectedUom(); if (uom == null) { throw new Exception(DesignerLocalizer.instance().getErrorString("unit.cannot.be.null")); } // make sure that there is a non-null category uom.getCategory(); PersistenceService.instance().fetchReferencedUnits(uom); PersistenceService.instance().save(uom); onRefreshAllUoms(); } catch (Exception e) { AppUtils.showErrorDialog(e); } }
Example 18
Source File: FunctionStage.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override protected void initialize(Stage stage) { super.initialize(stage); stage.initModality(Modality.APPLICATION_MODAL); }
Example 19
Source File: CreditsStage.java From marathonv5 with Apache License 2.0 | 4 votes |
@Override protected void initialize(Stage stage) { super.initialize(stage); stage.initModality(Modality.APPLICATION_MODAL); }
Example 20
Source File: NameEditor.java From OpenLabeler with Apache License 2.0 | 4 votes |
public String showPopup(double screenX, double screenY, Window window) { Scene scene = new Scene(this); Stage popupStage = new Stage(StageStyle.UNDECORATED); String label = text.getText(); popupStage.addEventFilter(KeyEvent.KEY_PRESSED, event -> { switch (event.getCode()) { case ESCAPE: { text.setText(label); // discard change popupStage.close(); break; } case ENTER: { int index = list.getSelectionModel().getSelectedIndex(); if (index >= 0) { text.setText(list.getSelectionModel().getSelectedItem()); } if (text.getText().trim().isEmpty()) { text.setText(label); } popupStage.close(); break; } case UP: { list.requestFocus(); break; } case DOWN: { list.requestFocus(); if (list.getSelectionModel().getSelectedIndex() < 0) { list.getSelectionModel().select(0); } break; } // JavaFX bug - ListView#selectionModel#select does not scroll into view /* case UP: { int index = list.getSelectionModel().getSelectedIndex(); index = index < 0 ? 0 : (index == 0 ? list.getItems().size() - 1 : index - 1); list.getSelectionModel().select(index); event.consume(); break; } case DOWN: { int index = list.getSelectionModel().getSelectedIndex(); index = index < 0 ? 0 : (index == list.getItems().size() - 1 ? 0 : index + 1); list.getSelectionModel().select(index); event.consume(); break; } */ } }); popupStage.focusedProperty().addListener((obs, wasFocused, isNowFocused) -> { if (!isNowFocused) { if (text.getText().trim().isEmpty()) { text.setText(label); } popupStage.hide(); } }); popupStage.initOwner(window); popupStage.initModality(Modality.WINDOW_MODAL); popupStage.setScene(scene); // Show the stage close to the mouse pointer popupStage.setX(screenX + 10); popupStage.setY(screenY + 10); popupStage.showAndWait(); return text.getText(); }