File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in MessageDialog" Watch "Problem in MessageDialog" New topic

Problem in MessageDialog

Sham Usha

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: 15302

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

Joined: Apr 15, 2005
Posts: 10
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();
if(c instanceof Frame)
return (Frame)c;
c = c.getParent();

I agree. Here's the link:
subject: Problem in MessageDialog
It's not a secret anymore!