Display a wizard-style JavaFX dialog. - Java JavaFX

Java examples for JavaFX:Dialog

Description

Display a wizard-style JavaFX dialog.

Demo Code


import javafx.application.ConditionalFeature;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.Window;

public class Main{
    private static volatile Stage stage;
    private static volatile StageStyle stageStyle;
    /**/*from  w w  w. j a  v  a2  s.c  o m*/
     * Display a wizard-style dialog. This is used to show a multi-step dialog that can iteratively process a methodology
     * for creating or editing data.
     * @param window A {@link Window} object, representing the parent window.
     * @param title  A {@link String} object, representing the dialog title.
     * @param scene  A {@link WizardScene} object, representing the wizard content.
     * @param width  An {@link Integer} value, representing the minimal width.
     * @see DialogUtility
     */
    public static synchronized final void displayWizard(Window window,
            String title, WizardScene scene, int width) {
        DialogUtility.stageCreate(window, stageStyle, title, width);

        stage.setScene(scene);
        stage.showAndWait();
        DialogUtility.stageFinish();
    }
    /**
     * Create a dialog stage. This takes a number of parameterized objects to create an active dialog window.
     * @param w A {@link Window} object, representing the parent window.
     * @param s A {@link StageStyle} object, representing the stage style.
     * @param t A {@link String} object, representing the dialog title.
     * @param i An {@link Integer} value, representing the minimal width.
     * @see DialogUtility
     * @see Modality
     * @see Stage
     * @see StageStyle
     * @see String
     * @see Window
     */
    private static synchronized void stageCreate(Window w, StageStyle s,
            String t, int i) {
        DialogUtility.stageFinish();
        stage = new Stage(s);
        stage.initOwner(w);
        stage.initModality(Modality.WINDOW_MODAL);
        stage.setTitle(t);
        stage.setMinWidth(i);
    }
    /**
     * Dispose of the dialog.
     * @see DialogUtility
     */
    private static synchronized void stageFinish() {
        if (stage != null) {
            stage = null;
        }
    }
}

Related Tutorials