List of usage examples for javafx.stage Stage setOnShown
public final void setOnShown(EventHandler<WindowEvent> value)
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
public void setStage(final Stage stage) { this.stage = stage; stage.setOnShown(new EventHandler<WindowEvent>() { @Override//from w w w. j av a 2 s .c om public void handle(WindowEvent event) { ObservableList<Screen> screens = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); if (screens != null && screens.size() > 0) { SCREEN_WIDTH = screens.get(0).getBounds().getWidth(); SCREEN_HEIGHT = screens.get(0).getBounds().getHeight(); } } }); viewer3DPanelController.setStage(stage); }
From source file:org.beryx.viewreka.fxapp.ProjectLibs.java
public void installLibs(String prjName, File prjDir) { InstallLibsTask task = new InstallLibsTask(prjName, prjDir, lstLib); Stage progressStage = new Stage(); progressStage.setOnCloseRequest(ev -> { if (Dialogs.confirmYesNo("Cancel", "Are you sure you want to cancel the installation of project libraries?", null)) { task.cancel();//w w w .j av a 2s. com } }); progressStage.initStyle(StageStyle.UTILITY); progressStage.initModality(Modality.APPLICATION_MODAL); progressStage.setTitle("Create project " + prjName); GridPane grid = new GridPane(); grid.setHgap(20); grid.setVgap(20); grid.setPadding(new Insets(24, 10, 0, 24)); ProgressIndicator progressIndicator = new ProgressIndicator(); progressIndicator.setPrefSize(64, 64); progressIndicator.setMinSize(64, 64); progressIndicator.setMaxSize(64, 64); // progressIndicator.progressProperty().bind(task.progressProperty()); grid.add(progressIndicator, 0, 0); Label actionLabel = new Label("Install project libraries..."); actionLabel.textProperty().bind(task.messageProperty()); grid.add(actionLabel, 1, 0); progressStage.setScene(new Scene(grid, 600, 120)); task.setOnSucceeded(ev -> closeProgress(progressStage, task)); task.setOnFailed(ev -> closeProgress(progressStage, task)); task.setOnCancelled(ev -> closeProgress(progressStage, task)); progressStage.setOnShown(ev -> Executors.newSingleThreadExecutor().submit(task)); progressStage.showAndWait(); }
From source file:spdxedit.PackageEditor.java
/** * Opens the modal package editor for the provided package. * * @param pkg The package to edit. * @param relatablePackages Packages to which the edited package may optionally have defined relationships * @param parentWindow The parent window. *///from w w w . j a v a2 s. co m public static void editPackage(final SpdxPackage pkg, final List<SpdxPackage> relatablePackages, SpdxDocumentContainer documentContainer, Window parentWindow) { final PackageEditor packageEditor = new PackageEditor(pkg, relatablePackages, documentContainer); final Stage dialogStage = new Stage(); dialogStage.setTitle("Edit SPDX Package: " + pkg.getName()); dialogStage.initStyle(StageStyle.DECORATED); dialogStage.initModality(Modality.APPLICATION_MODAL); dialogStage.setY(parentWindow.getX() + parentWindow.getWidth() / 2); dialogStage.setY(parentWindow.getY() + parentWindow.getHeight() / 2); dialogStage.setResizable(false); try { FXMLLoader loader = new FXMLLoader(NewPackageDialog.class.getResource("/PackageEditor.fxml")); loader.setController(packageEditor); Pane pane = loader.load(); Scene scene = new Scene(pane); dialogStage.setScene(scene); dialogStage.getIcons().clear(); dialogStage.getIcons().add(UiUtils.ICON_IMAGE_VIEW.getImage()); //Populate the file list on appearance dialogStage.setOnShown(event -> { try { final SpdxFile dummyfile = new SpdxFile(pkg.getName(), null, null, null, null, null, null, null, null, null, null, null, null); TreeItem<SpdxFile> root = new TreeItem<>(dummyfile); packageEditor.filesTable.setRoot(root); //Assume a package without is external //TODO: replace with external packages or whatever alternate mechanism in 2.1 packageEditor.btnAddFile.setDisable(pkg.getFiles().length == 0); root.getChildren() .setAll(Stream.of(pkg.getFiles()) .sorted(Comparator.comparing(file -> StringUtils.lowerCase(file.getName()))) //Sort by file name .map(TreeItem<SpdxFile>::new).collect(Collectors.toList())); } catch (InvalidSPDXAnalysisException e) { logger.error("Unable to get files for package " + pkg.getName(), e); } packageEditor.tabFiles.setExpanded(true); }); //Won't assign this event through FXML - don't want to propagate the stage beyond this point. packageEditor.btnOk.setOnMouseClicked(event -> dialogStage.close()); dialogStage.showAndWait(); } catch (IOException ioe) { throw new RuntimeException("Unable to load dialog", ioe); } }