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

If JComboBox is open when closing the window, it stays open next time.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.0, 1.3.0
    • client-libs
    • beta
    • x86
    • windows_nt



      Name: skT88420 Date: 07/28/99


      If one closes the window with with upper right corner X-button
      when JComboBox is open, it stays open when the same window
      is shown again. JComboBox cannot be closed after that, so
      it hides other components.

      Problem occurs, if windowClosing makes setVisible(false).
      For example we have dispatched all windowClosings to
      cancelButton event handlers for checkings etc., and
      there we close the window with setVisible(false).

      Example program:

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

      public class Combo
      {
          private static JDialog m_dialog;

          private static class DialogClose
              extends WindowAdapter
          {
              public void windowClosing(WindowEvent event)
              { // this leaves the comboBox open
                  // also when showing window again
                  m_dialog.setVisible(false);
              }
          }

          public static final void main(String[] args)
          {
              // Create a dialog with one JComboBox
              m_dialog = new JDialog();
              m_dialog.setSize(100, 100);
              JComboBox combo = new JComboBox();
              combo.addItem("test item 1");
              combo.addItem("test item 2");
              m_dialog.getContentPane().setLayout(new FlowLayout());
              m_dialog.getContentPane().add(combo);
              m_dialog.addWindowListener(new Combo.DialogClose());

              // Create a frame for showing the dialog
              JFrame frame = new JFrame();
              JButton openButton = new JButton("Open");
              openButton.addActionListener(
                  new ActionListener()
                  {
                      public void actionPerformed(ActionEvent event)
                      {
                          m_dialog.setVisible(true);
                      }
                  }
                  );
              frame.getContentPane().setLayout(new FlowLayout());
              frame.getContentPane().add(openButton);
              frame.addWindowListener(
                  new WindowAdapter()
                  {
                      public void windowClosing(WindowEvent event)
                      {
                          System.exit(0);
                      }
                  });
              frame.setSize(100, 100);
              frame.setVisible(true);
          }
      }


      java version "1.2"
      HotSpot VM (1.0fcs, mixed mode, build E)
      java full version "JDK-1.2-V"
      (Review ID: 93142)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: