List of usage examples for javafx.stage Stage getX
public final double getX()
From source file:cz.lbenda.rcp.DialogHelper.java
public void openWindowInCenterOfStage(Stage parentStage, Pane pane, String title) { Stage stage = new Stage(); stage.setTitle(title);/*from ww w . j a v a 2 s. com*/ stage.setScene(new Scene(pane, pane.getPrefWidth(), pane.getPrefHeight())); stage.getIcons().addAll(parentStage.getIcons()); stage.show(); stage.setX(parentStage.getX() + (parentStage.getWidth() - stage.getWidth()) / 2); stage.setY(parentStage.getY() + (parentStage.getHeight() - stage.getHeight()) / 2); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void showUpcomingEvents() { try {/*from w ww. j a v a2 s . co m*/ final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/UpcomingView.fxml")); final Parent root = loader.load(); final Stage stage = new Stage(); final Scene scene = new Scene(root); stage.setTitle("What's next"); stage.setScene(scene); stage.setWidth(600); stage.setHeight(400); final Stage windowStage = (Stage) node.getScene().getWindow(); stage.setX(windowStage.getX() + windowStage.getWidth() / 2 - stage.getWidth() / 2); stage.setY((windowStage.getY() + windowStage.getHeight()) / 2 - stage.getHeight() / 2); final UpcomingController c = loader.getController(); c.setManager(getManager()); stage.show(); } catch (final IOException e) { logger.error(e.getLocalizedMessage(), e); } }
From source file:acmi.l2.clientmod.l2smr.Controller.java
private void showUmodel(final String obj, final String file) { Platform.runLater(() -> {/* w w w .java2 s. c o m*/ try { FXMLLoader loader = new FXMLLoader(getClass().getResource("smview/smview.fxml")); loader.load(); SMView controller = loader.getController(); controller.setStaticmesh(getStaticMeshDir(), file, obj); Scene scene = new Scene(loader.getRoot()); scene.setOnKeyReleased(controller::onKeyReleased); Stage smStage = new Stage(); smStage.setScene(scene); smStage.setTitle(obj); smStage.show(); smStage.setX(Double.parseDouble(L2smr.getPrefs().get("smview.x", String.valueOf(smStage.getX())))); smStage.setY(Double.parseDouble(L2smr.getPrefs().get("smview.y", String.valueOf(smStage.getY())))); smStage.setWidth(Double .parseDouble(L2smr.getPrefs().get("smview.width", String.valueOf(smStage.getWidth())))); smStage.setHeight(Double .parseDouble(L2smr.getPrefs().get("smview.height", String.valueOf(smStage.getHeight())))); InvalidationListener listener = observable -> { L2smr.getPrefs().put("smview.x", String.valueOf(Math.round(smStage.getX()))); L2smr.getPrefs().put("smview.y", String.valueOf(Math.round(smStage.getY()))); L2smr.getPrefs().put("smview.width", String.valueOf(Math.round(smStage.getWidth()))); L2smr.getPrefs().put("smview.height", String.valueOf(Math.round(smStage.getHeight()))); }; smStage.xProperty().addListener(listener); smStage.yProperty().addListener(listener); smStage.widthProperty().addListener(listener); smStage.heightProperty().addListener(listener); } catch (IOException e) { onException("Couldn't show staticmesh", e); } }); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void showAddBookingDialog(final LocalDate date, final String roomName) { try {//from w ww. ja v a 2 s. c o m final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/AddBookingView.fxml")); final Parent root = loader.load(); final Stage stage = new Stage(); stage.setWidth(300); stage.setHeight(600); final Scene scene = new Scene(root); stage.setTitle("Add BookingBean"); stage.setScene(scene); final AddBookingController c = loader.getController(); c.setManager(manager); c.datePickerCheckIn.setValue(date); c.comboBoxRoom.getSelectionModel().select(roomName); final Stage windowStage = (Stage) node.getScene().getWindow(); stage.initOwner(windowStage); stage.initModality(Modality.WINDOW_MODAL); stage.setX(windowStage.getX() + windowStage.getWidth() / 2 - stage.getWidth() / 2); stage.setY((windowStage.getY() + windowStage.getHeight()) / 2 - stage.getHeight() / 2); stage.show(); } catch (final IOException e) { logger.error(e.getLocalizedMessage(), e); } }
From source file:de.chaosfisch.uploader.gui.GUIUploader.java
private void initApplication(final Stage primaryStage) { try {/*from w w w . j av a 2s .c o m*/ final Parent parent = fxmlLoader .load(getClass().getResource("/de/chaosfisch/uploader/view/SimpleJavaYoutubeUploader.fxml"), resources) .getRoot(); final Scene scene = SceneBuilder.create().root(parent).fill(Color.TRANSPARENT).build(); try (InputStream iconInputStream = getClass() .getResourceAsStream("/de/chaosfisch/uploader/resources/images/film.png")) { StageBuilder.create().icons(new Image(iconInputStream)).minHeight(MIN_HEIGHT).height(MIN_HEIGHT) .minWidth(MIN_WIDTH).width(MIN_WIDTH).scene(scene).resizable(true) .onCloseRequest(new ApplicationClosePromptDialog()).applyTo(primaryStage); } parent.setOnMouseDragged(new EventHandler<MouseEvent>() { @Override public void handle(final MouseEvent me) { primaryStage.setX(me.getScreenX() - initX); primaryStage.setY(me.getScreenY() - initY); } }); parent.setOnMousePressed(new EventHandler<MouseEvent>() { @Override public void handle(final MouseEvent me) { initX = me.getScreenX() - primaryStage.getX(); initY = me.getScreenY() - primaryStage.getY(); } }); primaryStage.initStyle(StageStyle.TRANSPARENT); primaryStage.show(); } catch (final IOException e) { LOGGER.error("FXML Load error", e); throw new RuntimeException(e); } }
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 a v 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.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * Refreshes the complete layout and returns the bounds of the given * Component./*from w w w . ja v a 2 s . c o m*/ * * @param comp * the Component * @param clickOp * not used * @return Rectangle with the Bounds */ private Rectangle getComponentBounds(final Object comp, ClickOptions clickOp) { ComponentHandler.syncStageResize(); Rectangle bounds = null; if (comp instanceof Stage) { Stage s = (Stage) comp; bounds = new Rectangle(new Point(Rounding.round(s.getX()), Rounding.round(s.getY()))); // This is not multi display compatible Screen screen = Screen.getPrimary(); final Rectangle2D screenBounds = screen.getBounds(); int displayWidth = Rounding.round(screenBounds.getWidth()); int displayHeight = Rounding.round(screenBounds.getHeight()); if (s.isFullScreen()) { bounds.width = Rounding.round(displayWidth); bounds.height = Rounding.round(displayHeight); } else if (s.isMaximized()) { int x = Rounding.round(s.getX()); int y = Rounding.round(s.getY()); // trimming the bounds to the display if necessary bounds.width = Rounding.round(s.getWidth()); bounds.height = Rounding.round(s.getHeight()); if (x < 0 || y < 0) { bounds.x = 0; bounds.y = 0; if (bounds.width > displayWidth) { bounds.width = displayWidth; } if (bounds.height > displayHeight) { bounds.height = displayHeight; } } } else { bounds.width = Rounding.round(s.getWidth()); bounds.height = Rounding.round(s.getHeight()); } } else { final Node node = (Node) comp; if (clickOp.isScrollToVisible()) { ensureComponentVisible(node); } bounds = EventThreadQueuerJavaFXImpl.invokeAndWait("Robot get node bounds", new Callable<Rectangle>() { //$NON-NLS-1$ @Override public Rectangle call() throws Exception { Rectangle bs = new Rectangle(getLocation(node, new Point(0, 0))); Bounds b = node.getBoundsInParent(); bs.width = Rounding.round(b.getWidth()); bs.height = Rounding.round(b.getHeight()); return bs; } }); } return bounds; }
From source file:org.jamocha.gui.JamochaGui.java
private void saveState(final Stage primaryStage) { final Preferences userPrefs = Preferences.userNodeForPackage(getClass()); userPrefs.putDouble("stage.x", primaryStage.getX()); userPrefs.putDouble("stage.y", primaryStage.getY()); userPrefs.putDouble("stage.width", primaryStage.getWidth()); userPrefs.putDouble("stage.height", primaryStage.getHeight()); }