wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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.
 
wood burning stoves
 
subject: Problem in MessageDialog
 
Similar Threads
Strange - Page Submits!!!
WA #1.....word association
Showing an external system in Sequence Diagram
Connecting to Unix via Windows
How to copy a file from linux to windows and vise versa using java swing