Java Code Examples for javafx.stage.Stage#getScene()

The following examples show how to use javafx.stage.Stage#getScene() . 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: StagePopup.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
/**
 Set's the popup's primary stage.

 @throws IllegalStateException if invoked when popup has already been made visible at some point
 */
protected void setPrimaryStage(@Nullable final Stage primaryStage) {
	if (primaryStage != null) {
		if (myStage.getOwner() != null) {
			myStage.getIcons().remove(primaryStage.getIcons().get(0));
			myStage.getScene().getStylesheets().removeAll(primaryStage.getScene().getStylesheets());
			primaryStage.getScene().getStylesheets().removeListener(stageStylesheetListener);
		}

		myStage.initOwner(primaryStage);
		if (primaryStage.getIcons().size() > 0) {
			myStage.getIcons().add(primaryStage.getIcons().get(0));
		}
		if (primaryStage.getScene() != null) {
			myStage.getScene().getStylesheets().addAll(primaryStage.getScene().getStylesheets());
			primaryStage.getScene().getStylesheets().addListener(stageStylesheetListener);
		}
	}
}
 
Example 2
Source File: MarsNode.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public MarsNode(MainScene mainScene, Stage stage) {
	this.mainScene = mainScene;
	this.stage = stage;
	this.scene = stage.getScene();

	//windowManager = new FXDesktopWindowManager();

}
 
Example 3
Source File: MenuBarUtils.java    From NSMenuFX with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void setMenuBar(Stage stage, MenuBar menuBar) {
	Scene scene = stage.getScene();
	if (scene != null) {
		ObservableList<Node> children = getChildren(scene.getRoot());
		if (children != null) {
			setMenuBar(children, menuBar);
		}
	}
}
 
Example 4
Source File: CSSFXTesterApp.java    From cssfx with Apache License 2.0 5 votes vote down vote up
public void initUI(Stage stage) {
    Scene s = stage.getScene(); 

    String cssURI = getClass().getResource("app.css").toExternalForm();
    s.getStylesheets().add(cssURI);
    
    btnLoadOddCSS.setOnAction((ae) -> s.getStylesheets().add(getClass().getResource("oddeven.css").toExternalForm()));
}
 
Example 5
Source File: ContractRFXIOSApp.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
    super.start(primaryStage);
    
    Scene scene = primaryStage.getScene();
    scene.getStylesheets().add(ContractRFXIOSApp.class.getResource("iOSTheme.css").toExternalForm());
}
 
Example 6
Source File: Toast.java    From mapper-generator-javafx with Apache License 2.0 4 votes vote down vote up
public static void makeText(Stage stage, String message, final int displayTime, int fadeInDelay, final int fadeOutDelay, double size, double opacity) {
    final Stage toastStage = new Stage();
    toastStage.initOwner(stage);
    toastStage.setResizable(false);
    toastStage.initStyle(StageStyle.TRANSPARENT);
    Text text = new Text(message);
    text.setFont(Font.font("Verdana", size));
    text.setFill(Color.RED);
    StackPane root = new StackPane((Node) text);
    root.setStyle("-fx-background-radius: 20; -fx-background-color: rgba(0, 0, 0, 0.2); -fx-padding: 50px;");
    root.setOpacity(opacity);
    Scene scene = new Scene(root);
    scene.setFill(Color.TRANSPARENT);
    toastStage.setScene(scene);
    toastStage.show();
    Timeline fadeInTimeline = new Timeline();
    Duration var10002 = Duration.millis((double) fadeInDelay);
    KeyValue[] var10003 = new KeyValue[1];
    Scene var10008 = toastStage.getScene();
    var10003[0] = new KeyValue(var10008.getRoot().opacityProperty(), 1);
    KeyFrame fadeInKey1 = new KeyFrame(var10002, var10003);
    fadeInTimeline.getKeyFrames().add(fadeInKey1);
    fadeInTimeline.setOnFinished(event -> (new Thread((() -> {
        try {
            Thread.sleep((long) displayTime);
        } catch (InterruptedException var3) {
            var3.printStackTrace();
        }

        Timeline fadeOutTimeline = new Timeline();
        Duration var100021 = Duration.millis((double) fadeOutDelay);
        KeyValue[] var100031 = new KeyValue[1];
        Scene var100081 = toastStage.getScene();
        var100031[0] = new KeyValue(var100081.getRoot().opacityProperty(), 0);
        KeyFrame fadeOutKey1 = new KeyFrame(var100021, var100031);
        fadeOutTimeline.getKeyFrames().add(fadeOutKey1);
        fadeOutTimeline.setOnFinished(event1 -> {
            toastStage.close();
        });
        fadeOutTimeline.play();
    }))).start());
    fadeInTimeline.play();
}
 
Example 7
Source File: ThemeManager.java    From MSPaintIDE with MIT License 4 votes vote down vote up
public void addStage(Stage stage) {
    Scene scene = stage.getScene();
    stage.setOnCloseRequest(event -> removeScene(scene));
    if (!this.scenes.contains(scene)) this.scenes.add(scene);
    selectThemeName(this.activeName);
}
 
Example 8
Source File: GUITest.java    From density-converter with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    controller = GUI.setup(stage, new TestPreferenceStore(), new Dimension(1920, 1080));
    stage.show();
    scene = stage.getScene();
}
 
Example 9
Source File: GitFxToolBarTest.java    From GitFx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    scene=stage.getScene();
}
 
Example 10
Source File: GitFxApplicationLaunchTest.java    From GitFx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    scene=stage.getScene();
}
 
Example 11
Source File: GitFxHistoryScrollPaneTest.java    From GitFx with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
    scene=stage.getScene();
}