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

setMnemonic on JButton makes it "clickable" under modal JDialog

XMLWordPrintable

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

      Name: jk109818 Date: 07/28/2003


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

      FULL OS VERSION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      I have tried put a JButton on a frame with setMnemonic
      It is clickable even after a modal dialog popped on screen which
      is supposed to be blocking the button.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Just have a try on the program Test1 attached.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect pressing "alt-o" has no effect when the modal dialog is showing on screen.
      ACTUAL -
      If you click "on frame" button, it will pop a dialog which is modal. Your mouse can't click the button again until the dialog is close. However if you use the mnemonic 'o' by pressing 'alt-o' even the modal dialog is showing. You can pop another model dialog on screen.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

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

      public class Test1 extends JFrame implements ActionListener {
        
        private int clickCount;
        
        public Test1() {
          super("test");
          
          JButton onFrameButton=new JButton("on frame");
          onFrameButton.setMnemonic('o');
          onFrameButton.setActionCommand("onFrame");
          onFrameButton.addActionListener(this);
          
          super.getContentPane().add(onFrameButton);
          
          clickCount=0;
          
          pack();
          show();
        }
        
        public void actionPerformed(ActionEvent e) {
          if (e.getActionCommand().equals("onFrame")) {
            JDialog d=new JDialog(this, "testing", true);
            clickCount++;
            d.getContentPane().add(new JLabel("clicked "+clickCount+" times"));
            d.pack();
            d.setLocationRelativeTo(this);
            d.show();
          }
        }
        
        public static void main(String[] args) {
          new Test1();
        }
      }
      ---------- END SOURCE ----------
      (Incident Review ID: 192702)
      ======================================================================
      ###@###.### 11/1/04 14:43 GMT

            draskinsunw Daniel Raskin (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: