Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JOptionPane keeps popping up behind windows

797160Sep 30 2009 — edited Dec 10 2009
I'm having trouble with my JOptionPane popping up behind my main window, rather than in front. On the advise of someone more experienced than me, I encased the JOptionPane in a JDialog, as follows:
                 

Object[] array = 
{
        new JLabel("Enter some text:"),          };

 
     JOptionPane pane = new JOptionPane(array, 
JOptionPane.ERROR_MESSAGE);
     JDialog dialog = pane.createDialog(null, "Result 
Data");  
     
dialog.setResizable(true);
     
dialog.setVisible(true);
     dialog.toFront();
and it keeps appearing behind all my windows.
The first time the program runs each session, it pops up behind all the windows, making hte program appear to hang. If I alt-Tab and bring it front, all is fine, and then subsequent iterations of the dialog come up in front
Can anyone help me makes sure these boxes pop up in front every time?
Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2010
Added on Sep 30 2009
13 comments
1,593 views