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

JComboBox popup loses mouse events in nested modal dialog on repeated use.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • client-libs



      Name: gm110360 Date: 02/11/2004


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

      FULL OS VERSION :
      Multiple Windows versions
      Not reproducible on solaris

      A DESCRIPTION OF THE PROBLEM :
      See example code...

      Start with a JFrame. This frame opens a modal JDialog. This dialog in turn opens another modal JDialog. The second modal dialog contains a JComboBox which, when it's popup is made visible, extends beyond the bounds of the containing dialog. The combo box popup behaves normally on the first use of the dialog. Now, close both dialogs but not the frame. Open the first dialog. Open the second dialog. Now click the combo box. The popup is no longer receiving mouse events. Key selection still works however.

      If the second dialog is made larger so the popup does not exceed the bounds of the dialog, the problem of repeated use does not exist.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the included code and execute
      the MultipleModalDialogTest class.

      1. Click the button in the frame to show the first dialog.
      2. Click the button in the first dialog to show the second dialog.
      3. Click the combo box and verify that mouse selection works.
      4. Close the second dialog.
      5. Close the first dialog.
      6. Click the button in the frame to show the first dialog.
      7. Click the button in the first dialog to show the second dialog.
      8. Click the combo box and try to use the mouse for selection.



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The combo box popup should be receptive to mouse events on repeated use of the dialogs.
      ACTUAL -
      The combo box popup does not accept mouse events when the dialogs are closed and then reopened.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

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

      public class MultipleModalDialogTest extends JFrame {
        private JButton button = new JButton();
        private FirstModalDialog dialog;

        public MultipleModalDialogTest() {
          dialog = new FirstModalDialog(this);
          button.setText("Show First Dialog");
          button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              button_actionPerformed(e);
            }
          });
          this.getContentPane().setLayout(new FlowLayout());
          this.getContentPane().add(button, null);
          setTitle("Dialog Test");
          setSize(200, 120);
          setDefaultCloseOperation(3);
          setVisible(true);
        }

        public static void main(String[] args) {
          MultipleModalDialogTest test = new MultipleModalDialogTest();
        }

        void button_actionPerformed(ActionEvent e) {
          dialog.setVisible(true);
        }

      }

      class FirstModalDialog extends JDialog {
        private JButton button = new JButton();
        private SecondModalDialog dialog;

        public FirstModalDialog(Frame frame) {
          super(frame);
          dialog = new SecondModalDialog(frame);
          button.setText("Show Second Dialog");
          button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
              button_actionPerformed(e);
            }
          });
          this.getContentPane().setLayout(new FlowLayout());
          this.getContentPane().add(button, null);
          setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
          setModal(true);
          setSize(180, 100);
        }

        void button_actionPerformed(ActionEvent e) {
          dialog.setVisible(true);
        }

      }

      class SecondModalDialog extends JDialog {
        private JComboBox comboBox = new JComboBox();

        public SecondModalDialog(Frame frame) {
          super(frame);
          comboBox.addItem("One");
          comboBox.addItem("Two");
          comboBox.addItem("Three");
          comboBox.addItem("Four");
          this.getContentPane().setLayout(new FlowLayout());
          this.getContentPane().add(comboBox);
          // at this size, the combo box popup will go outside
          // the bounds of the dialog
          setSize(160, 80);
          setTitle("Second Modal Dialog");
          setModal(true);
        }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Ensure that the combo box popup does not exceed the bounds of the containing dialog window.
      (Incident Review ID: 189907)
      ======================================================================

            kizune Alexander Zuev
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: