List of usage examples for javafx.stage Stage initOwner
public final void initOwner(Window owner)
From source file:io.bitsquare.app.BitsquareApp.java
private void showDebugWindow() { ViewLoader viewLoader = injector.getInstance(ViewLoader.class); View debugView = viewLoader.load(DebugView.class); Parent parent = (Parent) debugView.getRoot(); Stage stage = new Stage(); stage.setScene(new Scene(parent)); stage.setTitle("Debug window"); stage.initModality(Modality.NONE);//from w w w. ja v a 2 s . c o m stage.initStyle(StageStyle.UTILITY); stage.initOwner(scene.getWindow()); stage.setX(primaryStage.getX() + primaryStage.getWidth() + 10); stage.setY(primaryStage.getY()); stage.show(); }
From source file:tachyon.view.ProjectProperties.java
public ProjectProperties(JavaProject project, Window w) { this.project = project; stage = new Stage(); stage.initOwner(w);/*from ww w .j av a 2s . co 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:main.Content.java
public boolean showInputDialog(Activity aktivitet) { try {//from w ww .jav a 2s. 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:ca.wumbo.doommanager.client.controller.FileEditorController.java
/** * Creates a new DXML project and has the user set it up, then places it in * the tab./* www . j a v a 2 s .c o m*/ */ public void newDXMLProject() { // Create the wizard and wait for the result. DXMLProjectCreatorController controller = SpringContainer.getContext() .getBean(DXMLProjectCreatorController.class); Scene scene = new Scene(controller.getRootPane()); scene.getStylesheets().add(cssPath); Stage stage = new Stage(); stage.setTitle("DXML Project Setup Wizard"); stage.setResizable(false); stage.initModality(Modality.WINDOW_MODAL); stage.initOwner(coreController.getStage()); stage.setScene(scene); controller.setStage(stage); // Required for it to be able to close properly. controller.setParentStage(coreController.getStage()); // Required as well to block input if browsing for files. stage.showAndWait(); // If the user finished the work, get the DXML file. if (!controller.wasClosedByUser()) { DXML dxmlData = controller.getDxmlData(); // The file must also be valid. This should not ever be false unless there is a coding error. if (dxmlData.isValidDXMLFile()) { // Create it on the disk. DXMLCreationStatus status = dxmlData.createOnDisk(); // If the status shows success, add it to the view. switch (status) { case SUCCESS: // Since it succeeded, open up the project now. String path = dxmlData.getProjectInfo().getProjectLocationPath() + File.separator; path += dxmlData.getCompilation().getFilename() + File.separator; path += dxmlData.getCompilation().getFilename() + ".dxml"; // TODO - support any case extension. openDXMLProject(Paths.get(path)); break; case ALREADY_EXISTS: log.warn("DXML project already exists at the specified location. Aborting."); break; case FOLDER_CREATION_FAILURE: log.warn("Unable to create directory for the project. Are your permissions correct? Aborting."); break; case DXML_FILE_EXISTS: log.warn("DXML file already exists at location, aborting to prevent potential overwrite."); break; case DXML_FILE_CREATION_FAILURE: log.warn("Unable to create DXML file at location, are your permissions correct? Aborting."); break; case XML_MARSHALL_ERROR: log.warn("Unable to create the .dxml file. Are your file permissions correct? Aborting."); break; case FAILED: log.warn("Unable to create the necessary DXML file/folder resources at the provided location."); break; case INVALID_DXML_DATA: case BAD_PROJECT_PATH: log.warn("DXML project has corrupt data. Contact a developer, Aborting [Reason: {}].", status.name()); break; default: throw new DXMLException( "DXML status for disk creation returned an unexpected enumeration. Contact a developer."); } } else { throw new DXMLException( "DXML Wizard has not properly generated a proper file. Please contact a developer."); } } else { log.info("DXML project cancelled by user."); } }
From source file:gov.va.isaac.sync.view.SyncView.java
/** * @see gov.va.isaac.interfaces.gui.views.PopupViewI#showView(javafx.stage.Window) */// w w w.ja v a2s .c o m @Override public void showView(Window parent) { initGui(); Stage stage = new Stage(StageStyle.DECORATED); stage.initModality(Modality.NONE); stage.initOwner(parent); Scene scene = new Scene(root_); stage.setScene(scene); stage.setTitle("Datastore Synchronization"); stage.getScene().getStylesheets().add(SyncView.class.getResource("/isaac-shared-styles.css").toString()); stage.sizeToScene(); stage.show(); stage.setOnCloseRequest(windowEvent -> { if (running_.get()) { windowEvent.consume(); } }); }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Perform functionality associated with "About" menu selection or CTRL-A. *///w w w . ja v a 2s. c om 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 confirmation dialog/*from w w w . j a v a 2 s.c om*/ */ 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:jp.co.heppokoact.autocapture.FXMLDocumentController.java
/** * ???????????/* w ww . j a v a 2 s . c om*/ * ???????? * ???ESC???????? * * @return ??????? * @throws IOException ????? */ private Stage createTransparentStage() throws IOException { // ?????????? Stage transparentStage = new Stage(StageStyle.TRANSPARENT); transparentStage.initOwner(anchorPane.getScene().getWindow()); transparentStage.initModality(Modality.APPLICATION_MODAL); transparentStage.setResizable(false); Rectangle2D rect = Screen.getPrimary().getVisualBounds(); transparentStage.setWidth(rect.getWidth()); transparentStage.setHeight(rect.getHeight()); // ??? java.awt.Rectangle awtRect = new java.awt.Rectangle((int) rect.getWidth(), (int) rect.getHeight()); BufferedImage captureImage = robot.createScreenCapture(awtRect); // ?????? ByteArrayInputStream in = ImageUtil.convToInputStream(captureImage); BackgroundImage bgImage = new BackgroundImage(new Image(in), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT); Pane pane = new Pane(); pane.setBackground(new Background(bgImage)); pane.setStyle("-fx-border-color: rgba(255, 255, 0, 0.5); -fx-border-style: solid; -fx-border-width: 15;"); // ???ESC????? Scene scene = new Scene(pane); transparentStage.setScene(scene); scene.setOnKeyPressed(e -> { if (e.getCode() == KeyCode.ESCAPE) { transparentStage.close(); } }); return transparentStage; }
From source file:com.esri.geoevent.test.performance.ui.OrchestratorController.java
/** * Shows the report options dialog// w ww . jav a 2 s.com */ 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 va2s . c o 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(); } }