Refine search
btnOpenNewWindow.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { Parent root; try { root = FXMLLoader.load(getClass().getClassLoader().getResource("path/to/other/view.fxml"), resources); Stage stage = new Stage(); stage.setTitle("My New Stage Title"); stage.setScene(new Scene(root, 450, 450)); stage.show(); // Hide this current window (if this is what you want) ((Node)(event.getSource())).getScene().getWindow().hide(); } catch (IOException e) { e.printStackTrace(); } } }
private Stage createStage(Stage mainStage) { FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("event-log.fxml")); 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; }
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(); } ... }
private void clickShow(ActionEvent event) { Stage stage = new Stage(); Parent root = FXMLLoader.load( YourClassController.class.getResource("YourClass.fxml")); stage.setScene(new Scene(root)); stage.setTitle("My modal window"); stage.initModality(Modality.WINDOW_MODAL); stage.initOwner( ((Node)event.getSource()).getScene().getWindow() ); stage.show(); }
private Stage createEditPropertyDialog() { EditPropertyDialogController wizard = new EditPropertyDialogController(); FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("edit-property-dialog.fxml")); loader.setController(wizard); final Stage dialog = new Stage(); dialog.initOwner(this.getScene().getWindow()); dialog.initModality(Modality.WINDOW_MODAL); dialog.initStyle(StageStyle.UNDECORATED); Parent root; try { root = loader.load(); } catch (IOException e) { throw new IllegalStateException(e); } Scene scene = new Scene(root); dialog.setTitle("Edit property"); dialog.setScene(scene); dialog.setUserData(wizard); return dialog; }
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();
public class CenterStage extends Application { @Override public void start(final Stage stage) throws Exception { stage.setX(300); stage.setWidth(800); stage.setHeight(400); stage.show(); final Stage childStage = new Stage(); childStage.setWidth(200); childStage.setHeight(200); childStage.setX(stage.getX() + stage.getWidth() / 2 - childStage.getWidth() / 2); childStage.setY(stage.getY() + stage.getHeight() / 2 - childStage.getHeight() / 2); childStage.show(); } 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(); }
try{ FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("Demo.fxml")); Parent root1 = (Parent) fxmlLoader.load(); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initStyle(StageStyle.UNDECORATED); stage.setTitle("ABC"); stage.setScene(new Scene(root1)); stage.show(); }