@FXML private javafx.scene.control.Button closeButton; @FXML private void closeButtonAction(){ // get a handle to the stage Stage stage = (Stage) closeButton.getScene().getWindow(); // do what you have to do stage.close(); }
public void setOnHidden(EventHandler<WindowEvent> onHidden) { dialog.setOnHidden(onHidden); }
private void fixPosition() { Window w = dialog.getOwner(); Screen s = com.sun.javafx.util.Utils.getScreen(w); Rectangle2D sb = s.getBounds(); double xR = w.getX() + w.getWidth(); double xL = w.getX() - dialog.getWidth(); double x; double y; if (sb.getMaxX() >= xR + dialog.getWidth()) { x = xR; } else if (sb.getMinX() <= xL) { x = xL; } else { x = Math.max(sb.getMinX(), sb.getMaxX() - dialog.getWidth()); } y = Math.max(sb.getMinY(), Math.min(sb.getMaxY() - dialog.getHeight(), w.getY())); dialog.setX(x); dialog.setY(y); }
@Override public void openProject(ReuseStage reuse) { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open .json File"); fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("JSON files (*.json)", "*.json")); final File file = fileChooser.showOpenDialog(stage); if (file != null) { configFileHelper.loadConfigFile(file, reuse); } }
public void showPopup() { myPopupStage.show(); popupBinding = bindPopupToThisController(); }
Stage dialog = new Stage(); // populate dialog with controls. ... dialog.initOwner(parentStage); dialog.initModality(Modality.ApplicationModal); dialog.showAndWait(); // process result of dialog operation. ...
private void onSelectFileClicked() { FileChooser chooser = new FileChooser(); chooser.setTitle("Add files to the auxilliary classpath"); chooser.getExtensionFilters().addAll( new FileChooser.ExtensionFilter("Java archives", "*.jar", "*.war", "*.ear"), new FileChooser.ExtensionFilter("Java class files", "*.class") ); List<File> files = chooser.showOpenMultipleDialog(designerRoot.getMainStage()); fileListView.getItems().addAll(files); }
private void updateInitMouseValues(MouseEvent mouseEvent) { initStageX = primaryStage.getX(); initStageY = primaryStage.getY(); initWidth = primaryStage.getWidth(); initHeight = primaryStage.getHeight(); initX = mouseEvent.getScreenX(); initY = mouseEvent.getScreenY(); xOffset = mouseEvent.getSceneX(); yOffset = mouseEvent.getSceneY(); }
@Override public void invalidated(Observable ignored) { if (Double.isNaN(dialog.getWidth()) || Double.isNaN(dialog.getHeight())) { return; } dialog.widthProperty().removeListener(positionAdjuster); dialog.heightProperty().removeListener(positionAdjuster); fixPosition(); } };
@Override public void update(Observable o, Object arg) { Platform.runLater(new Runnable() { public void run() { new anotherApp().start(new Stage()); } } }
boolean setStageHeight(double height) { if (height >= primaryStage.getMinHeight() && height >= buttonsContainer.getHeight()) { primaryStage.setHeight(height); // initY = newY; return true; } else if (height >= primaryStage.getMinHeight() && height <= buttonsContainer.getHeight()) { height = buttonsContainer.getHeight(); primaryStage.setHeight(height); } return false; }
boolean setStageWidth(double width) { if (width >= primaryStage.getMinWidth() && width >= buttonsContainer.getMinWidth()) { primaryStage.setWidth(width); // initX = newX; return true; } else if (width >= primaryStage.getMinWidth() && width <= buttonsContainer.getMinWidth()) { width = buttonsContainer.getMinWidth(); primaryStage.setWidth(width); } return false; }
@Override public void start(Stage primaryStage) { primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent e) { Platform.exit(); System.exit(0); } }); }
public void hidePopup() { myPopupStage.hide(); popupBinding.unsubscribe(); popupBinding = () -> {}; }
public void setMaximized(boolean b) { designerRoot.getMainStage().setMaximized(!b); // trigger change listener anyway designerRoot.getMainStage().setMaximized(b); }
@Override protected double computePrefWidth(double height) { Window owner = getOwner(); if (owner != null) { return owner.getWidth(); } else { return super.computePrefWidth(height); } }
Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); primaryStage.setX(bounds.getMinX()); primaryStage.setY(bounds.getMinY()); primaryStage.setWidth(bounds.getWidth()); primaryStage.setHeight(bounds.getHeight());
@Override protected double computePrefHeight(double width) { Window owner = getOwner(); if (owner != null) { return owner.getHeight(); } else { return super.computePrefHeight(width); } }
@Override public void quit() { stage.close(); }