JDK-4765314 : JWindow behaves differently than JFrame
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.0
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-10-18
  • Updated: 2003-08-12
  • Resolved: 2003-08-12
Related Reports
Duplicate :  
Description

Name: sv35042			Date: 10/18/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
Service Pack 2



A DESCRIPTION OF THE PROBLEM :
When an application displays a JWindow and then disposes it,
the application does not terminate without a call to
System.exit().

If the same application uses a JFrame instead of JWindow, it
does terminate.

It seems like the dispose() method does not releases all of
the screen resources used by JWindow, causing the VM to
think that something belonging to the application is still
running.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run the accompanying source code.
Optional:
2. Switch the comments to the declaration of the frame
variable to make it a JFrame instead of JWindow.
3. Compile and run again.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
Since the display() method of this class "disposes" the
JWindow before it returns back to main, the application
should terminate when the main method is finished executing.

Actual:
The application does not terminate. Evidence of this is,
when running from a command prompt, the command prompt never
returns.
If the application displays and disposes a JWindow, the
application terminates as expected.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;

class testGUI
{
   void display()
   {
//      JFrame myWindow = new JFrame("title");  // works
      JWindow myWindow = new JWindow();  // does not work

      JPanel pane = new JPanel();
      myWindow.getContentPane().add(pane);

      final JLabel labelTitle = new JLabel("Hello");
      pane.add(labelTitle);

      myWindow.pack();

      myWindow.setVisible(true);

      try
      {
         Thread.sleep(5000);
      }
      catch (Exception e) { }

      myWindow.dispose();
   }

   public static void main(String[] args)
   {
      (new testGUI()).display();
      System.out.println("Done.");
   }
}

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
Use JFrame instead of JWindow.
(Review ID: 159252) 
======================================================================

Comments
EVALUATION I believe this was fixed as part of Andrey's fix for 4895582, reassigning to Andrey for confirmation. ###@###.### 2003-08-11 Name: apR10133 Date: 08/12/2003 As it is mentioned above this bug was fixed by the changes for bugs 4859570 and 4895582. ###@###.### ======================================================================
24-08-2004