Stage dialog = new Stage(); // populate dialog with controls. ... dialog.initOwner(parentStage); dialog.initModality(Modality.ApplicationModal); dialog.showAndWait(); // process result of dialog operation. ...
String nextText = readLineFromSource(); if ("MISSING".equals(nextText)) { updateMessage("Prompting for missing text"); FutureTask<String> futureTask = new FutureTask( new MissingTextPrompt() ); Platform.runLater(futureTask); nextText = futureTask.get(); } ... class MissingTextPrompt implements Callable<String> { private TextField textField; @Override public String call() throws Exception { final Stage dialog = new Stage(); dialog.setScene(createDialogScene()); dialog.showAndWait(); return textField.getText(); } ... }
public void showAndWait() { if(canShow) { _prepareShow(false); dialogStage.showAndWait(); canShow = false; } }
public void displayRootSelection(Consumer<String> callback){//EDIT, usage see below Stage window = new Stage(); currentWindow = window; Main.setRootInSelection(true); try { BorderPane root = ...; /*...*/ window.showAndWait(); // When the code reaches this position, your modal window is closed String tempId = AreaManagement.getTempAreaId(); // You can call just about anything here callback.accept(tempId); } catch (IOException e) { e.printStackTrace(); } }
public class ShowOff extends Application { @Override public void start(Stage primaryStage) { HelloScreen hello = new HelloScreen(); primaryStage.setScene(new Scene(hello.getView())); // show stage and wait until it closes: primaryStage.showAndWait(); String message = hello.getMessage(); // do something with message... System.out.println(message); } public static void main(String[] args) { Application.launch(args); } }
void dialogPreferences() throws IOException { Stage dialogStage = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource( "PiPreference.fxml")); loader.setController(new PiPreferenceController("")); BorderPane root = (BorderPane) loader.load(); Scene scene = new Scene(root); dialogStage.setScene(scene); dialogStage.showAndWait(); }
Stage dialogStage = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource("Dialog.fxml")); AnchorPane root = (AnchorPane)loader.load(); DialogController controller = (DialogController) loader.getController(); Scene scene = new Scene(root); dialogStage.setScene(scene); dialogStage.showAndWait();
Thread t = new Thread(() -> { doSomeStuff(); Platform.runLater(() -> { Stage dialog = new Stage(); dialog.initStyle(StageStyle.UTILITY); Scene scene = new Scene(new Group(new Text(25, 25, "All is done!"))); dialog.setScene(scene); dialog.showAndWait(); }); }); t.start();
public static <T> T showWindow(String path){ try { FXMLLoader fxmlLoader = new FXMLLoader(ShowWindow.class.getResource(path)); Parent root = fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.setScene(new Scene(root)); stage.showAndWait(); return fxmlLoader.getController(); }catch(IOException ex){ ex.printStackTrace(); } return null; }
FXMLLoader loader = new FXMLLoader(...); Scene scene = new Scene(loader.load()); Stage loginPopup = new Stage(); loginPopup.setScene(scene); LoginController loginController = loader.getController(); loginPopup.showAndWait(); MyLoginData data = loginController.getLoginData(); // process data...
public void loadOptionsWindow(){ Stage modal = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource("/optionsWindow.fxml")); OptionsWindowController opwCotroller = loader.getController(); modal.initModality(Modality.APPLICATION_MODAL); Parent optionsRoot = null; try { optionsRoot = loader.load(); Scene sceneOptions = new Scene(optionsRoot); modal.setScene(sceneOptions); opwCotroller.init(modal); modal.showAndWait(); } catch (IOException e) { e.printStackTrace(); } }
@FXML public void do() throws Exception { FXMLLoader fxmlLoader = new FXMLLoader(this.getClass().getResource("/fxml/myPage.fxml")); Parent root = (Parent)fxmlLoader.load(); Scene mainScene = new Scene(root); Stage stage = new Stage(); stage.setHeight(500); stage.setWidth(400); stage.setScene(mainScene); stage.setTitle("Provide input"); stage.showAndWait(); // get results of input here... System.out.println(Thread.currentThread().getName() +"returned"); }
FXMLLoader loader = new FXMLLoader(getClass().getResource("second.fxml")); Stage subStage = new Stage(); subStage.initModality(Modality.APPLICATION_MODAL); subStage.setTitle("Second Window"); Scene scene = new Scene(loader.load()); subStage.setScene(scene); subStage.showAndWait(); Optional<Person> result = loader.<Supplier<Optional<Person>>>getController().get(); if (result.isPresent()) { // do something with the result }
final FXMLLoader isLoader = new FXMLLoader(Main.class.getResource("/view/itemStep.fxml")); final AnchorPane pane = isLoader.load(); final Scene scene = new Scene(pane); final Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.setScene(scene); listViewVariable.setOnMouseClicked(event -> { if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && (mouseEvent.getClickCount() == 2)) { ItemStep item = listViewVariable.getSelectionModel().getSelectedItem(); if (item != null) { stage.showAndWait(); item.setUrl(item.urlField.getText()); } } });
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/org/yourcompanyname/yourapplicationname/layouts/nameOfYourFxmlFile.fxml")); Parent root = fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.setOpacity(1); stage.setTitle("My New Stage Title"); stage.setScene(new Scene(root, 450, 450)); stage.showAndWait();
@FXML private void addCustomer(ActionEvent event) throws IOException { Stage stage; Parent root; stage = new Stage(); FXMLLoader loader = new FXMLLoader(getClass().getResource("FXMLpopUp1.fxml")); root = loader.load(); PopupController popupController = loader.getController(); stage.setScene(new Scene(root)); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(addCustomerButton.getScene().getWindow()); stage.showAndWait(); if (popupController.isConfirmed()) { // confirm button was pressed... } }
Stage stage = new Stage(); FXMLLoader fxmlLoader = new FXMLLoader( getClass().getResource("../layout/SearchCustomer.fxml")); Parent parent = (Parent) fxmlLoader.load(); ChildController childController = fxmlLoader.getController(); childController.currentCustomerProperty().addListener((obs, oldCustomer, newCustomer) -> { // do whatever you need with newCustomer.... }); Scene scene = new Scene(parent); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(parent.getScene().getWindow()); stage.setScene(scene); stage.resizableProperty().setValue(false); stage.showAndWait();
animation.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { Platform.runLater(new Runnable() { @Override public void run() { Stage stage = new Stage(); StackPane pane = new StackPane(); pane.getChildren().add(new Label("Hello world")); stage.setScene(new Scene(pane, 100, 100)); stage.showAndWait(); } }); } });
public void openGuiColorsDialog() { FXMLLoader loader = new FXMLLoader(getClass().getResource("GuiColors.fxml")); GuiColorsController guiColorsController = new GuiColorsController(previewPane.getScene(), settingsModel); loader.setController(guiColorsController); try { AnchorPane guiColorsPane = (AnchorPane)loader.load(); Scene scene = new Scene(guiColorsPane); Stage dialog = new Stage(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.setScene(scene); dialog.showAndWait(); } catch (IOException e) { e.printStackTrace(); } }
class CreateStage { private TextField textBox ; public CreateStage() { textBox = new TextField(); StackPane root = new StackPane(); root.getChildren().add(textBox); Scene scene = new Scene(root, 300, 250); Stage stage = new Stage(); stage.setTitle("Additional Stage"); stage.setScene(scene); stage.initModality(Modality.APPLICATION_MODAL); stage.showAndWait(); } public String getText() { return textBox.getText(); } }