Java Code Examples for javafx.stage.Stage#getHeight()
The following examples show how to use
javafx.stage.Stage#getHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StageControllerImpl.java From scenic-view with GNU General Public License v3.0 | 6 votes |
public void placeStage(final Stage stage) { if (targetWindow != null) { stage.setX(targetWindow.getX() + targetWindow.getWidth()); stage.setY(targetWindow.getY()); try { // Prevents putting the stage out of the screen final Screen primary = Screen.getPrimary(); if (primary != null) { final Rectangle2D rect = primary.getVisualBounds(); if (stage.getX() + stage.getWidth() > rect.getMaxX()) { stage.setX(rect.getMaxX() - stage.getWidth()); } if (stage.getY() + stage.getHeight() > rect.getMaxY()) { stage.setX(rect.getMaxY() - stage.getHeight()); } } } catch (final Exception e) { ExceptionLogger.submitException(e); } } }
Example 2
Source File: WikiButton.java From pattypan with MIT License | 6 votes |
public void goTo(String paneName, Stage stage, boolean clearScenes) { if (clearScenes) { Session.SCENES = new HashMap<>(); } Scene scene = Session.SCENES.containsKey(paneName) ? Session.SCENES.get(paneName) : new Scene(getPaneByPaneName(paneName, stage), Util.WINDOW_WIDTH, Util.WINDOW_HEIGHT); if(!Session.SCENES.containsKey(paneName)) { Session.SCENES.put(paneName, scene); } double oldWidth = stage.getWidth(); double oldHeight = stage.getHeight(); stage.setScene(scene); stage.setWidth(oldWidth); stage.setHeight(oldHeight); }
Example 3
Source File: CrewEditorFX.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private Image copyBackground(Stage stage) { final int X = (int) stage.getX(); final int Y = (int) stage.getY(); final int W = (int) stage.getWidth(); final int H = (int) stage.getHeight(); try { java.awt.Robot robot = new java.awt.Robot(); java.awt.image.BufferedImage image = robot.createScreenCapture(new java.awt.Rectangle(X, Y, W, H)); return SwingFXUtils.toFXImage(image, null); } catch (java.awt.AWTException e) { System.out.println("The robot of doom strikes!"); e.printStackTrace(); return null; } }
Example 4
Source File: FrostyTech.java From mars-sim with GNU General Public License v3.0 | 6 votes |
private Image copyBackground(Stage stage) { final int X = (int) stage.getX(); final int Y = (int) stage.getY(); final int W = (int) stage.getWidth(); final int H = (int) stage.getHeight(); try { java.awt.Robot robot = new java.awt.Robot(); java.awt.image.BufferedImage image = robot.createScreenCapture(new java.awt.Rectangle(X, Y, W, H)); return SwingFXUtils.toFXImage(image, null); } catch (java.awt.AWTException e) { System.out.println("The robot of doom strikes!"); e.printStackTrace(); return null; } }
Example 5
Source File: AboutController.java From Animu-Downloaderu with MIT License | 5 votes |
@FXML private void donate() { var dialog = new DonateDialog(); Stage stage = (Stage) root.getScene().getWindow(); // an ugly way of initializing stage // Calculate the center position of the parent Stage double centerXPosition = stage.getX() + stage.getWidth() / 2d; double centerYPosition = stage.getY() + stage.getHeight() / 2d; dialog.setOnShowing(e -> { dialog.setX(centerXPosition - dialog.getDialogPane().getWidth() / 2d); dialog.setY(centerYPosition - dialog.getDialogPane().getHeight() / 2d); }); dialog.showAndWait(); }
Example 6
Source File: FrostyTech.java From mars-sim with GNU General Public License v3.0 | 5 votes |
private javafx.scene.shape.Rectangle makeSmoke(Stage stage) { return new javafx.scene.shape.Rectangle( stage.getWidth(), stage.getHeight(), Color.WHITESMOKE.deriveColor( 0, 1, 1, 0.08 ) ); }
Example 7
Source File: Frosty.java From Cryogen with GNU General Public License v2.0 | 5 votes |
private javafx.scene.shape.Rectangle makeSmoke(Stage stage) { javafx.scene.shape.Rectangle rect = new javafx.scene.shape.Rectangle( stage.getWidth(), stage.getHeight(), Color.WHITESMOKE.deriveColor( 0, 1, 1, 0.08 ) ); return rect; }
Example 8
Source File: WindowSettingsParameter.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
/** * Set window size and position according to the values in this instance */ public void applySettingsToWindow(@Nonnull final Stage stage) { logger.finest("Setting window " + stage.getTitle() + " position " + posX + ":" + posY + " and size " + width + "x" + height); if (posX != null) stage.setX(posX); if (posY != null) stage.setX(posY); if (width != null) stage.setWidth(width); if (height != null) stage.setHeight(height); if ((isMaximized != null) && isMaximized) { logger.finest("Setting window " + stage.getTitle() + " to maximized"); stage.setMaximized(true); } // when still outside of screen // e.g. changing from 2 screens to one if (stage.isShowing() && !isOnScreen(stage)) { // Maximize on screen 1 logger.finest( "Window " + stage.getTitle() + " is not on screen, setting to maximized on screen 1"); stage.setX(0.0); stage.setY(0.0); stage.sizeToScene(); stage.setMaximized(true); } ChangeListener<Number> stageListener = (observable, oldValue, newValue) -> { posX = stage.getX(); posY = stage.getY(); width = stage.getWidth(); height = stage.getHeight(); }; stage.widthProperty().addListener(stageListener); stage.heightProperty().addListener(stageListener); stage.xProperty().addListener(stageListener); stage.yProperty().addListener(stageListener); }
Example 9
Source File: WindowSettingsParameter.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
private boolean isOnScreen(Stage stage) { Rectangle2D stagePosition = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); var screens = Screen.getScreensForRectangle(stagePosition); return !screens.isEmpty(); }
Example 10
Source File: HelpBox.java From scenic-view with GNU General Public License v3.0 | 4 votes |
public static HelpBox make(final String title, final String url, final Stage stage) { DisplayUtils.showWebView(true); final HelpBox node = new HelpBox(title, url, stage.getX() + (stage.getWidth() / 2) - (SCENE_WIDTH / 2), stage.getY() + (stage.getHeight() / 2) - (SCENE_HEIGHT / 2)); return node; }
Example 11
Source File: UndecoratorController.java From DevToolBox with GNU Lesser General Public License v2.1 | 4 votes |
public void saveBounds() { Stage stage = undecorator.getStage(); savedBounds = new BoundingBox(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); }
Example 12
Source File: UndecoratorController.java From DevToolBox with GNU Lesser General Public License v2.1 | 4 votes |
public void saveFullScreenBounds() { Stage stage = undecorator.getStage(); savedFullScreenBounds = new BoundingBox(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); }
Example 13
Source File: XdatEditor.java From xdat_editor with MIT License | 4 votes |
@Override public void start(Stage primaryStage) throws Exception { this.stage = primaryStage; FXMLLoader loader = new FXMLLoader(getClass().getResource("main.fxml"), interfaceResources); loader.setClassLoader(getClass().getClassLoader()); loader.setControllerFactory(param -> new Controller(XdatEditor.this)); Parent root = loader.load(); controller = loader.getController(); primaryStage.setTitle("XDAT Editor"); primaryStage.setScene(new Scene(root)); primaryStage.setWidth(Double.parseDouble(windowPrefs().get("width", String.valueOf(primaryStage.getWidth())))); primaryStage.setHeight(Double.parseDouble(windowPrefs().get("height", String.valueOf(primaryStage.getHeight())))); if (windowPrefs().getBoolean("maximized", primaryStage.isMaximized())) { primaryStage.setMaximized(true); } else { Rectangle2D bounds = new Rectangle2D( Double.parseDouble(windowPrefs().get("x", String.valueOf(primaryStage.getX()))), Double.parseDouble(windowPrefs().get("y", String.valueOf(primaryStage.getY()))), primaryStage.getWidth(), primaryStage.getHeight()); if (Screen.getScreens() .stream() .map(Screen::getVisualBounds) .anyMatch(r -> r.intersects(bounds))) { primaryStage.setX(bounds.getMinX()); primaryStage.setY(bounds.getMinY()); } } primaryStage.show(); Platform.runLater(() -> { InvalidationListener listener = observable -> { if (primaryStage.isMaximized()) { windowPrefs().putBoolean("maximized", true); } else { windowPrefs().putBoolean("maximized", false); windowPrefs().put("x", String.valueOf(Math.round(primaryStage.getX()))); windowPrefs().put("y", String.valueOf(Math.round(primaryStage.getY()))); windowPrefs().put("width", String.valueOf(Math.round(primaryStage.getWidth()))); windowPrefs().put("height", String.valueOf(Math.round(primaryStage.getHeight()))); } }; primaryStage.xProperty().addListener(listener); primaryStage.yProperty().addListener(listener); primaryStage.widthProperty().addListener(listener); primaryStage.heightProperty().addListener(listener); }); Platform.runLater(this::postShow); }
Example 14
Source File: CrewEditorFX.java From mars-sim with GNU General Public License v3.0 | 4 votes |
private javafx.scene.shape.Rectangle makeSmoke(Stage stage) { return new javafx.scene.shape.Rectangle(stage.getWidth(), stage.getHeight(), Color.WHITESMOKE.deriveColor(0, 1, 1, 0.2 // 0.08 )); }