mynameisJEFF
mynameisJEFF

Reputation: 4239

javafx: How to get back to original application window without closing the new window?

Apologies for asking such a simple question but english is not my first language, so I cannot find the right word to describe my problem and cannot google up the the right question.

I have a javafx application and there is a button whereby if the user clicks it, it generates a new window (like a display box just to display more info to a user). The problem is when the new window is displayed and I click anywhere of the Javafx application, I cannot get back to it. I have to close the new window first in order to interact with the original javafx application.

How can I have the ability to open the new window on a button click, while retaining the ability to interact the original javafx application without having to close the new window ?

        Button moreInfo = new Button("More Info");
        moreInfo.setOnAction(e -> {
            MoreInfoDisplayBox.display();
        });

public class MoreInfoDisplayBox {

    public static void display(){
        Stage window = new Stage();
        window.initModality(Modality.APPLICATION_MODAL);
        window.setTitle("More Info");
        window.setMinWidth(400);
        window.setMinHeight(400);
        window.show();
    }
}

Upvotes: 0

Views: 81

Answers (1)

James_D
James_D

Reputation: 209684

The behavior you describe is caused by calling

window.initModality(Modality.APPLICATION_MODAL);

(See docs.)

Instead, just use the default, which you can do explicitly with

window.initModality(Modality.NONE);

or of course just omit that line entirely.

Upvotes: 0

Related Questions