Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4765314

JWindow behaves differently than JFrame

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.4.0
    • client-libs



      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)
      ======================================================================

            apikalev Andrey Pikalev
            svioletsunw Scott Violet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: