Java Code Examples for javafx.scene.Scene#getWindow()
The following examples show how to use
javafx.scene.Scene#getWindow() .
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: Overlay.java From bisq with GNU Affero General Public License v3.0 | 6 votes |
protected void cleanup() { if (centerTime != null) centerTime.stop(); if (owner == null) owner = MainView.getRootContainer(); Scene rootScene = owner.getScene(); if (rootScene != null) { Window window = rootScene.getWindow(); if (window != null && positionListener != null) { window.xProperty().removeListener(positionListener); window.yProperty().removeListener(positionListener); window.widthProperty().removeListener(positionListener); } } }
Example 2
Source File: DockTools.java From FxDock with Apache License 2.0 | 6 votes |
public static FxDockWindow getWindow(Node n) { if(n != null) { Scene sc = n.getScene(); if(sc != null) { Window w = sc.getWindow(); if(w instanceof FxDockWindow) { return (FxDockWindow)w; } } } return null; }
Example 3
Source File: HelpDialogController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 4
Source File: SettingsDialogController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 5
Source File: ScoresDialogController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 6
Source File: AboutDialogController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 7
Source File: ScoresViewController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 8
Source File: AboutViewController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 9
Source File: HelpViewController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 10
Source File: SettingsViewController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 11
Source File: WindowsFx.java From FxDock with Apache License 2.0 | 5 votes |
protected FxWindow getFxWindow(Node n) { Scene sc = n.getScene(); if(sc != null) { Window w = sc.getWindow(); if(w instanceof FxWindow) { return (FxWindow)w; } } return null; }
Example 12
Source File: FX.java From FxDock with Apache License 2.0 | 5 votes |
public static FxWindow getWindow(Node n) { Scene sc = n.getScene(); if(sc != null) { Window w = sc.getWindow(); if(w instanceof FxWindow) { return (FxWindow)w; } } return null; }
Example 13
Source File: AboutDialogController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { // // For some reason, this.getScene() which is on the fx:root returns null // Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 14
Source File: GraphLayoutBehavior.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Updates the bounds property from the visual (viewport or nesting node) */ protected void updateBounds() { // XXX: Prevent bounds updates when the scene is not rendered. Scene scene = getHost().getVisual().getScene(); if (scene == null || scene.getWindow() == null) { return; } Rectangle newBounds = computeLayoutBounds(); Rectangle oldBounds = LayoutProperties.getBounds(getHost().getContent()); if (oldBounds != newBounds && (oldBounds == null || !oldBounds.equals(newBounds))) { LayoutProperties.setBounds(getHost().getContent(), newBounds); applyLayout(true, null); } }
Example 15
Source File: Initialization.java From trex-stateless-gui with Apache License 2.0 | 5 votes |
public static void initializeCloseEvent(Scene scene, EventHandler<WindowEvent> eventHandler) { Window window = scene.getWindow(); if (window == null) { scene.windowProperty().addListener((observableWindow, oldWindow, newWindow) -> { if (oldWindow == null && newWindow != null) { initializeCloseEvent(newWindow, eventHandler); } }); } else { initializeCloseEvent(window, eventHandler); } }
Example 16
Source File: DockPane.java From phoebus with Eclipse Public License 1.0 | 5 votes |
private void doAutoHideTabs(final Scene scene) { final boolean do_hide = getTabs().size() == 1 && !always_show_tabs; // Hack from https://www.snip2code.com/Snippet/300911/A-trick-to-hide-the-tab-area-in-a-JavaFX : // Locate the header's pane and set height to zero final StackPane header = findTabHeader(); if (header == null) logger.log(Level.WARNING, "Cannot locate tab header for " + getTabs()); else header.setPrefHeight(do_hide ? 0 : -1); // If header for single tab is not shown, // and this is the only tab in the window, // put its label into the window tile if (! (scene.getWindow() instanceof Stage)) throw new IllegalStateException("Expect Stage, got " + scene.getWindow()); final Stage stage = ((Stage) scene.getWindow()); if (do_hide && DockStage.getPaneOrSplit(stage) == this) { // Bind to get actual header, which for DockItemWithInput may contain 'dirty' marker, // and keep updating as it changes final Tab tab = getTabs().get(0); if (! (tab instanceof DockItem)) throw new IllegalStateException("Expected DockItem, got " + tab); stage.titleProperty().bind(((DockItem)tab).labelTextProperty()); } else { // Fixed title stage.titleProperty().unbind(); stage.setTitle(Messages.FixedTitle); } }
Example 17
Source File: Toast.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
private void doShow() { LOGGER.info("show toast: {}", this); if (window != null) { if (autoCenter) { connectAutoCenterHandler(); } if (Double.isNaN(screenX) || Double.isNaN(screenY)) { super.show(window); } else { super.show(window, screenX, screenY); } } else { // anchor if (autoCenter) { Scene scene = anchor.getScene(); if (scene != null) { window = scene.getWindow(); } if (window == null) { throw new IllegalStateException("anchor node is not attached to a window"); } connectAutoCenterHandler(); } super.show(anchor, Double.isNaN(screenX) ? 0.0 : screenX, Double.isNaN(screenY) ? 0.0 : screenY); } if (isAutoHide() && !duration.isIndefinite()) { hideTimer = new Timeline(new KeyFrame(duration)); hideTimer.setOnFinished((ActionEvent event) -> { hideTimer = null; Toast.this.hide(); }); hideTimer.playFromStart(); } FadeTransition transition = new FadeTransition(fadeInDuration, content); transition.setFromValue(0.0); transition.setToValue(contentOpacity); transition.play(); }
Example 18
Source File: ScoresDialogController.java From examples-javafx-repos1 with Apache License 2.0 | 5 votes |
@FXML public void close(ActionEvent evt) { Scene scene = ((Button)evt.getSource()).getScene(); if( scene != null ) { Window w = scene.getWindow(); if (w != null) { w.hide(); } } }
Example 19
Source File: Overlay.java From bisq with GNU Affero General Public License v3.0 | 4 votes |
public void display() { if (owner == null) owner = MainView.getRootContainer(); if (owner != null) { Scene rootScene = owner.getScene(); if (rootScene != null) { Scene scene = new Scene(getRootContainer()); scene.getStylesheets().setAll(rootScene.getStylesheets()); scene.setFill(Color.TRANSPARENT); setupKeyHandler(scene); stage = new Stage(); stage.setScene(scene); Window window = rootScene.getWindow(); setModality(); stage.initStyle(StageStyle.TRANSPARENT); stage.setOnCloseRequest(event -> { event.consume(); doClose(); }); stage.sizeToScene(); stage.show(); layout(); addEffectToBackground(); // On Linux the owner stage does not move the child stage as it does on Mac // So we need to apply centerPopup. Further with fast movements the handler loses // the latest position, with a delay it fixes that. // Also on Mac sometimes the popups are positioned outside of the main app, so keep it for all OS positionListener = (observable, oldValue, newValue) -> { if (stage != null) { layout(); if (centerTime != null) centerTime.stop(); centerTime = UserThread.runAfter(this::layout, 3); } }; window.xProperty().addListener(positionListener); window.yProperty().addListener(positionListener); window.widthProperty().addListener(positionListener); animateDisplay(); isDisplayed = true; } } }
Example 20
Source File: Game2048.java From Game2048FX with GNU General Public License v3.0 | 4 votes |
@Override public void postInit(Scene scene) { String display = Services.get(DisplayService.class) .map(service -> service.isTablet() ? "tablet" : "phone") .orElse("phone"); scene.getStylesheets().add(GameManager.class.getResource(display + ".css").toExternalForm()); GameModel gameModel = Injector.instantiateModelOrService(GameModel.class); scene.getRoot().getStyleClass().add(gameModel.getGameMode().toString().toLowerCase()); gameModel.gameModeProperty().addListener((obs, m, m1) -> { scene.getRoot().getStyleClass().remove(m.toString().toLowerCase()); scene.getRoot().getStyleClass().add(m1.toString().toLowerCase()); }); Stage stage = (Stage) scene.getWindow(); if (Platform.isDesktop()) { Services.get(DisplayService.class) .ifPresent(service -> { if (service.isTablet()) { // tablet scene.getWindow().setWidth(600); scene.getWindow().setHeight(800); } }); stage.setTitle("2048FX"); stage.getIcons() .add(new Image(GameManager.class.getResourceAsStream("Icon-60.png"))); } AppViewManager.GAME_VIEW.getPresenter().ifPresent(presenter -> { gamePresenter = (GamePresenter) presenter; gamePresenter.pauseProperty().bind(pause); gamePresenter.stopProperty().bind(stop); }); if (Platform.isDesktop() && isARMDevice()) { stage.setFullScreen(true); stage.setFullScreenExitHint(""); } if (javafx.application.Platform.isSupported(ConditionalFeature.INPUT_TOUCH)) { scene.setCursor(Cursor.NONE); } }