javafx.scene.Scene#getWindow ( )源码实例Demo

下面列出了javafx.scene.Scene#getWindow ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: bisq   文件: Overlay.java
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);
        }
    }
}
 
源代码2 项目: FxDock   文件: DockTools.java
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;	
}
 
@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();
        }
    }
}
 
@FXML
public void close(ActionEvent evt) {

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
源代码5 项目: DevToolBox   文件: Toast.java
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();
}
 
源代码6 项目: phoebus   文件: DockPane.java
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);
    }
}
 
源代码7 项目: trex-stateless-gui   文件: Initialization.java
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);
    }
}
 
源代码8 项目: gef   文件: GraphLayoutBehavior.java
/**
 * 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);
	}
}
 
@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();
        }
    }
}
 
源代码10 项目: FxDock   文件: FX.java
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;
}
 
源代码11 项目: FxDock   文件: WindowsFx.java
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;
}
 
@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();
        }
    }
}
 
@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();
        }
    }
}
 
@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();
        }
    }
}
 
@FXML
public void close(ActionEvent evt) {

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
@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();
        }
    }
}
 
@FXML
public void close(ActionEvent evt) {

    Scene scene = ((Button)evt.getSource()).getScene();
    if( scene != null ) {
        Window w = scene.getWindow();
        if (w != null) {
            w.hide();
        }
    }
}
 
@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();
        }
    }
}
 
源代码19 项目: bisq   文件: Overlay.java
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;
        }
    }
}
 
源代码20 项目: Game2048FX   文件: Game2048.java
@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);
    }
}