Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4508191
Votes 3
Synopsis JOptionPane.showInternalOptionDialog blocks after its enclosing JFrame is closed
Category java:classes_awt
Reported Against 1.3
Release Fixed 7(b10)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 4139692 , 6518753 , 6178755 , 4403925
Submit Date 27-SEP-2001
Description


java version "1.3.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)


  Description of bug:
------------------

JOptionPane.showInternalOptionDialog(...) and its ilk create internal dialogue
boxes designed for a JDesktopPane environment, but unlike JDialog,
JInternalFrame does not provide modal functionality - that is, it does not block
user input to other JInternalFrame objects in the same JDesktopPane.
This particular problem appears when an internal dialogue box appears, courtesy
of showInternalOptionDialog(...) or another such method in JOptionPane, and the
JFrame that contains it is closed before the dialogue is dismissed.  Everything
seems to be closed correctly, but the JOptionPane method never returns.  This
causes problems in our system when it tries to exit, with things hanging
mysteriously and never being terminated.

Sample source code:
------------------

Compile and run the following source code.  Try dismissing the dialogue box,
which will force the system to exit.  Run it again and close the window without
dismissing the dialogue box.  The JFrame will be disposed by a WindowAdapter,
but JOptionPane.showInternalMessageDialog(Component,Object,String,int) will
never return.

/** begin source code **/

import java.awt.event.*;
import javax.swing.*;


public class IFTest extends JFrame {

  public IFTest () {
    super ("Internal Frame test");
    setSize (640, 480);
    setContentPane (new JDesktopPane ());

    // just dispose on exit (the old 1.2 way)
    addWindowListener (new WindowAdapter () {
      public void windowClosing (WindowEvent we) {
        System.out.print ("Disposing of window...");
        dispose ();
        System.out.println ("done.");
      }
    });
  }

  public static void main (String[] args) {

    // somewhere for the internal dialogue box
    IFTest iftest = new IFTest ();
    iftest.setLocation (50, 50); // cascade frame a bit
    iftest.show ();

    // show the internal dialogue box
    JOptionPane.showInternalMessageDialog (
        iftest.getContentPane(),
        "Clicking OK will exit the system.\nClose the window and the system will hang.",
        "Test", JOptionPane.INFORMATION_MESSAGE
    );

    // once that's finished, force an exit
    System.out.println ("OK");
    System.exit (0);
  }

}

/** end source code **/

Suggestions:
-----------

The "correct" behaviour, as I see it, should be either:

  (a) closing the window should force the JOptionPane to return as if the
dialogue box was cancelled; or

  (b) block attempts to close the window if there is an internal (and,
eventually, modal) dialogue box in the JDesktopPane.

Neither of these seems particularly easy to me.

Post Scriptum:
-------------

This behaviour also appears in Beta 2 of the 1.4.0 Java Runtime Environment
(java -version reports: build 1.4.0-beta2-b77, mixed mode).
(Review ID: 132691) 
======================================================================
Posted Date : 2006-01-31 13:48:01.0
Work Around
N/A
Evaluation
Disposing the frame doesn't stop the application under 1.3.1 or before.  This
would cause the app to exit on 1.4 due to the AWT shutdown code except for the
fact that the OptionPane is waiting.  Maybe the startModal method in internal
frame should also make sure the parent is visible.
  xxxxx@xxxxx   2001-10-23
Although modality improvement has solved reprorted problem I found another one: if I close both a Dialog and a Frame then all application still working but no GUI is visible on the screen.
The initial problem goes away : now I can't close that JFrame until Dialog showing.
Posted Date : 2006-01-31 13:48:01.0

There is another CR that is tightly related to this one: 6178755. With the fix for that bug the behaviour of the test is the following. If I close the internal frame the whole application exits because of System.exit() call at the end of the test. At the same time the toplevel JFrame can't be closed because of option pane modality.

I'm not sure that this behaviour is just what's expected. If it is, then this bug should be closed after the fix for 6178755 is integrated.
Posted Date : 2006-09-29 15:14:59.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang