This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes Problem in MessageDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in MessageDialog" Watch "Problem in MessageDialog" New topic
Author

Problem in MessageDialog

Sham Usha
Greenhorn

Joined: Jul 22, 2001
Posts: 11
When my application is runing and there popup a meaasge dialog box(JOptionPane.showMessageDialog(......)).
If I select some other window in the screen the message box sent to back. How can I avoid that.

Pls Help
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The first parameter of a JOptionPane should be the parent component. Usually this is the JFrame from which it was launched. You are probably specifying null for this argument.



GenRocket - Experts at Building Test Data
sairam sam
Greenhorn

Joined: Apr 15, 2005
Posts: 10
Sham,
As Gregg said ur passing null value to the first parameter of the JOptionPane...
below is simple static method from my util class...which i use for the model dialog...on any module screens which basically extends the JPanel.

public static Frame findParentFrame(JPanel pan)
{
Component c = pan.getParent();
while(true)
{
if(c instanceof Frame)
return (Frame)c;
c = c.getParent();
}
}

Sai.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Problem in MessageDialog