I have 3 dialog that gets displayed together in my project.
- First dialog is modeless with
setVisibleOnTop(false)
. - Second dialog is modeless with
setVisibleOnTop(true)
. - Third dialog is Application Modal with
setVisibleOnTop(true)
.
Now the issue is :
- Ideally when there is a dialog "third" opened with
APPLICATION_MODAL
property then no otherJComponent
should accept the click. This works fine with java 1.7. - With java 1.6 is I click on dialog "one" then dialog "second" goes at the back of dialog "one". Whereas dialog "third" is still opened.
Now the question is:
- Why dialog "one" comes in front when there is an
APPLICATION_MODAL
dialog (third) opened? - Why second dialog with property
setAlwaysOnTop(true)
goes at back? - I believe this is a issue with java 1.6. Does anyone know about this?
- Is this bug documented somewhere?
Sample Code:
import java.awt.Frame;
import javax.swing.JDialog;
class MyDialog1 extends JDialog {
MyDialog1 ()
{
super();
super.setVisible(false);
setTitle("one");
}
}
class MyDialog2 extends JDialog {
MyDialog2 ()
{
super(null,ModalityType.MODELESS);
setAlwaysOnTop(true);
setTitle("second");
}
}
class MyDialog3 extends JDialog {
MyDialog3 ()
{
super(new Frame(),ModalityType.APPLICATION_MODAL);
setTitle("third");
setAlwaysOnTop(true);
super.setVisible(false);
}
}
public class ModalityIssue {
public static void main(String args[])
{
MyDialog1 d1=new MyDialog1();
d1.setSize(600, 600);
MyDialog2 d2=new MyDialog2();
d2.setSize(500, 500);
MyDialog3 d3=new MyDialog3();
d3.setSize(400, 400);
d1.setVisible(true);
d2.setLocationRelativeTo(d1);
d2.setVisible(true);
d3.setLocationRelativeTo(d2);
d3.setVisible(true);
}
}