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

Opening a dialog causes the app to never terminate.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 7u11, 7-pool
    • client-libs

      FULL PRODUCT VERSION :
      java version "1.7.0_11"
      Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
      Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Press the button to open the dialog at least once.
      When the main window is then closed, the "windowClosed fired" related to the dialog re-appears, and the JVM never completes.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See executable test case.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JVM terminates. Dialog closing action is not fired by the main window closing.
      ACTUAL -
      JVM does not terminate. Dialog closing action fires when the main window closes.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.AbstractAction;
      import javax.swing.JButton;
      import javax.swing.JDialog;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JOptionPane;
      import javax.swing.SwingUtilities;
      import javax.swing.WindowConstants;
      import java.awt.Dialog;
      import java.awt.event.ActionEvent;
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;

      public class DialogClosingBug implements Runnable
      {
          public static void main(String[] args)
          {
              SwingUtilities.invokeLater(new DialogClosingBug());
          }

          @Override
          public void run()
          {
              final JFrame frame = new JFrame("Test");
              frame.add(new JButton(new AbstractAction("Show Dialog")
              {
                  @Override
                  public void actionPerformed(ActionEvent event)
                  {
                      showDialog(frame);
                  }
              }));
              frame.pack();
              frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              frame.setVisible(true);
          }

          private void showDialog(final JFrame frame)
          {
              JDialog dialog = new JDialog(frame, "Dialog", Dialog.ModalityType.DOCUMENT_MODAL);
              dialog.add(new JLabel("Content here"));
              dialog.pack();
              dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
              dialog.addWindowListener(new WindowAdapter()
              {
                  @Override
                  public void windowClosed(WindowEvent event)
                  {
                      JOptionPane.showMessageDialog(frame, "windowClosed fired");
                  }
              });
              dialog.setVisible(true);
          }
      }
      ---------- END SOURCE ----------

            alitvinov Anton Litvinov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: