private void defaultStageStatus() { Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds(); stage.setX((primScreenBounds.getWidth() - stage.getWidth()) / 2); stage.setY((primScreenBounds.getHeight() - stage.getHeight()) / 4); stage.setMaximized(true); }
public HelpPopup(Region content) { getStyleClass().setAll("pdfsam-help-popup"); setAutoHide(true); setHideOnEscape(true); setAutoFix(true); this.content = content; this.content.setMaxWidth(Screen.getPrimary().getVisualBounds().getWidth() / 3); }
public static File captureScreenshot() { Path captureFile = Paths.get("screenshot" + new Date().getTime() + ".png"); Image captureImage = CAPTURE_SUPPORT.captureRegion(Screen.getPrimary().getBounds()); CAPTURE_SUPPORT.saveImage(captureImage, captureFile); return captureFile.toFile(); }
public static double getScreenHeight() { return Screen.getPrimary().getVisualBounds().getHeight(); }
public static double getScreenWidth() { return Screen.getPrimary().getVisualBounds().getWidth(); }
private static Object[] findInitialSize(String callee) { final Preferences prefs = Preferences.userRoot().node(callee.replace('.', '/')); Rectangle2D screen = Screen.getPrimary().getBounds(); double x = prefs.getDouble("x", screen.getWidth() * 0.05); // NOI18N double y = prefs.getDouble("y", screen.getHeight() * 0.05); // NOI18N double width = prefs.getDouble("width", screen.getWidth() * 0.9); // NOI18N double height = prefs.getDouble("height", screen.getHeight() * 0.9); // NOI18N Object[] arr = { x, y, width, height, null }; if (!callee.equals("org.netbeans.html")) { // NOI18N arr[4] = new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { Window window = (Window) event.getSource(); prefs.putDouble("x", window.getX()); // NOI18N prefs.putDouble("y", window.getY()); // NOI18N prefs.putDouble("width", window.getWidth()); // NOI18N prefs.putDouble("height", window.getHeight()); // NOI18N } }; } return arr; }
Screen screen = screens.isEmpty() ? Screen.getPrimary() : screens.get(0); Rectangle2D scrBounds = screen.getBounds(); int minX = (int)Math.round(scrBounds.getMinX());
private void _resize(final double width, final double height) { Window window = container.getScene().getWindow(); // size difference between root node and window depends on OS and Decorations double diffY = window.getHeight() - container.getHeight(); double diffX = window.getWidth() - container.getWidth(); webView.setMaxWidth(width); webView.setMaxHeight(height); webView.setMinWidth(width); webView.setMinHeight(height); javafx.geometry.Rectangle2D screenBounds = Screen.getPrimary().getBounds(); double scaleX = screenBounds.getWidth() / ( width + diffX ); double scaleY = screenBounds.getHeight() / ( height + diffY ); // calculate scale factor if too big for device, the .1 adds some padding double scale = Math.min(Math.min(scaleX, scaleY), 1.1) - .1; webView.setScaleX(scale); webView.setScaleY(scale); container.getScene().setRoot(new Group()); ((Stage)window).setScene(new Scene(container, width * scale, height * scale)); }
/** * Calculates the location of a window so that it will be centered on the screen. * * @param window the window * @return the location (top left corner) */ public Point2D determineCenteredLocation(Window window) { Rectangle2D screenSize = Screen.getPrimary().getVisualBounds(); // align sizes (for computation below) double windowWidth = window.getWidth(); double windowHeight = window.getHeight(); if (window.getWidth() > screenSize.getWidth()) { windowWidth = screenSize.getWidth(); } if (windowHeight > screenSize.getHeight()) { windowHeight = screenSize.getHeight(); } return new Point2D((screenSize.getWidth() - windowWidth) / 2.0, (screenSize.getHeight() - windowHeight) / 2.0); }
Screen screen = Screen.getScreens().stream().filter(s->s.getBounds().contains(centerX,centerY)).findFirst().orElse(Screen.getPrimary()); Rectangle2D screenBounds = screen.getBounds(); pane.setPrefWidth(screenBounds.getWidth()/3);
Rectangle2D screenSize = Screen.getPrimary().getVisualBounds();
Rectangle2D screenSize = Screen.getPrimary().getVisualBounds();