Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modal dialog hide behind Main Frame after swich focus

I have a swing application, basically, a main frame that could pop up a modal dialog. When the modal dialog is showing, if I switch to another window, like firefox. And then switch back to the swing application. The JDialog is not in front any more.

I don't want to set the dialog AlwaysOnTop to be true. because then the dialog will be on top of all windows include windows in other process.

So what should I do so that when I swich back, the modal dialog still on top?

BTW: it is a Applet, so the main frame is actually be set in this way:

private static Frame findParentFrame(Container owner){
    Container c = owner;
    while(c != null){
        if (c instanceof Frame)
            return (Frame)c;
        c = c.getParent();
    }
    return (Frame)null;
}
like image 667
Leon Avatar asked Oct 24 '22 15:10

Leon


1 Answers

Make sure that the JDialog is actually modal. Also try setting the main frame as the owner.

like image 111
jzd Avatar answered Oct 27 '22 05:10

jzd