show JavaFX Modal Window - Java JavaFX

Java examples for JavaFX:Stage

Description

show JavaFX Modal Window

Demo Code


//package com.java2s;

import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;

public class Main {
    public static void showModalWindow(Window parentWindow,
            Parent rootNode, String title, Image icon) {
        Stage stage = new Stage();
        stage.setScene(new Scene(rootNode));
        stage.setTitle(title);/* ww  w . ja  va 2 s .c  o m*/
        stage.getIcons().add(icon);
        stage.initModality(Modality.WINDOW_MODAL);
        stage.initOwner(parentWindow);
        stage.setResizable(false);
        stage.show();
    }
}

Related Tutorials