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

REGRESSION: CTRL-H menu item accelerator causes text removal in text components

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.5.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
      Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Linux home 2.6.10-1.770_FC3 #1 Thu Feb 24 14:00:06 EST 2005 i686 i686 i386 GNU/Linux

      Windows XP SP2

      A DESCRIPTION OF THE PROBLEM :
        Fix for Bug ID: 4782077 broke CTRL-H menu item accelerator's action for J2SE 1.5.0_0x. Instead of invoking the bound Replace action as described in http://java.sun.com/products/jlf/ed2/book/Appendix.A.html, text in the focused text component got deleted.

      The same shortcut works fine in J2SE 1.4.2.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Execute the program
      2. Type some text in the textarea
      3. Hit the key combo CTRL-H to bring up the Replace message box

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      CTRL-H should bring up the Replace message box.
      ACTUAL -
      Text in the textarea got deleted.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * TestCtrl_H.java
       *
       * Created on April 4, 2005, 12:10 AM
       */
      public class TestCtrl_H extends javax.swing.JFrame {
          
          /** Creates new form TestCtrl_H */
          public TestCtrl_H() {
              initComponents();
          }
          
          private void initComponents() {
              jTextArea1 = new javax.swing.JTextArea();
              jMenuBar1 = new javax.swing.JMenuBar();
              jMenuEdit = new javax.swing.JMenu();
              jMenuItemReplace = new javax.swing.JMenuItem();

              setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
              getContentPane().add(jTextArea1, java.awt.BorderLayout.CENTER);

              jMenuEdit.setText("Edit");
              jMenuItemReplace.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
              jMenuItemReplace.setText("Replace");
              jMenuItemReplace.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(java.awt.event.ActionEvent evt) {
                      jMenuItemReplaceActionPerformed(evt);
                  }
              });

              jMenuEdit.add(jMenuItemReplace);

              jMenuBar1.add(jMenuEdit);

              setJMenuBar(jMenuBar1);

              java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
              setBounds((screenSize.width-400)/2, (screenSize.height-300)/2, 400, 300);
          }

          private void jMenuItemReplaceActionPerformed(java.awt.event.ActionEvent evt) {
              // TODO add your handling code here:
              javax.swing.JOptionPane.showMessageDialog(null, "Replace");
          }
          
          /**
           * @param args the command line arguments
           */
          public static void main(String args[]) {
              java.awt.EventQueue.invokeLater(new Runnable() {
                  public void run() {
                      new TestCtrl_H().setVisible(true);
                  }
              });
          }
          
          // Variables declaration - do not modify
          private javax.swing.JMenuBar jMenuBar1;
          private javax.swing.JMenu jMenuEdit;
          private javax.swing.JMenuItem jMenuItemReplace;
          private javax.swing.JTextArea jTextArea1;
          // End of variables declaration
          
      }

      ---------- END SOURCE ----------

      Release Regression From : 1.4.2_05
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-04-04 09:45:17 GMT

            shickeysunw Shannon Hickey (Inactive)
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: