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

Infinite count of WINDOW_CLOSED events when dispose window owner

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P2 P2
    • None
    • 5.0
    • client-libs
    • None
    • x86
    • windows_2000



      Name: apR10133 Date: 07/24/2003


      The Window.dispose() method unconditionally posts WINDOW_CLOSED event,
      even if the window is not displayable. If the window disposes its owner
      on window closed it will cause the infinite loop of window's dispose and
      WINDOW_CLOSED event. I.e. when owner is disposed it calls dispose() for
      the owned window, which posts the WINDOW_CLOSED event and the owner is
      disposed again...

      This bug breaks the fixes for the 4859570 and 4726458.

      To reproduce this bug compile and run the test case below

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

      public class test {

             public static void main(String[] argv) {
      final JFrame f = new JFrame() {
      public void dispose() {
      super.dispose();
      System.out.println("Dispose owner frame!");
      }
      };
      JWindow w = new JWindow(f);
      w.addWindowListener(new WindowAdapter() {
      public void windowClosed(WindowEvent e) {
      System.out.println("Close window!");
      f.dispose();
      }
      });
      w.pack();
      w.dispose();
      try {
      Thread.sleep(3000);
      } catch(Exception e) {
      }
      System.out.println(w.getOwner().isDisplayable());
             }
      }
      ----------------------------------------------------------

      The output of the test is

      Close window!
      Dispose owner frame!
      Close window!
      Dispose owner frame!
      Close window!
      Dispose owner frame!
      ...

      ======================================================================

            ssisunw Ssi Ssi (Inactive)
            apikalev Andrey Pikalev
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: