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.showMessageDialog(new JFrame, "test"); hangs

843807Jun 14 2010 — edited Jun 14 2010
I have this code:
  public String readInputFile(String text) {
    JOptionPane.showMessageDialog(new JFrame(), text);
    // add stuff later here...
    return text;
  }
But when I run it from eclipse it never terminates (the red button never goes gray). But if I do:
  public String readInputFile(String text) {
    JFrame jFrame = new JFrame();
    JOptionPane.showMessageDialog(jFrame, text);
    // add stuff later here...
    jFrame.dispose();
    return text;
  }
it terminates nicely. But is it necessary to declare the JFrame as a local variable and call dispose to make this work?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 12 2010
Added on Jun 14 2010
7 comments
601 views