Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in MessageDialog

 
Sham Usha
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
sairam sam
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic