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

Numpad keys trigger more than one KeyEvent.

    Details

    • Subcomponent:
    • Resolved In Build:
      b64
    • CPU:
      sparc
    • OS:
      solaris_10

      Backports

        Description

        FULL PRODUCT VERSION :
        Java HotSpot(TM) Server VM (build 1.6.0_03-b05, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        SunOS dev-d01 5.10 Generic_127111-09 sun4u sparc SUNW,Sun-Fire-V440

        EXTRA RELEVANT SYSTEM CONFIGURATION :
        Window Manager: fvwm

        A DESCRIPTION OF THE PROBLEM :
        Under solaris with fvwm as the window manager, pressing any of the Number pad keys that have dual function, i.e. 7 - Home, 4 - Left, while Num Lock is on causes multiple KeyEvents are created. Essently, by pressing the num key 4, the cursor moves back one space and inserts a 4 instead of only inserting the number 4. When Num Lock is off, the keys have the correct behavior, no extra KeyEvents are created.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Create a new JTextField making sure your window manager is fvwm.

        When the screen comes up, make sure Num Lock is ON and try to enter data using the num pad. You should see each key producing odd behavior and multiple KeyEvents being created.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        You would expect that with Num Lock on the numbers would only insert the number.
        ACTUAL -
        Each key that has different functionally when Num Lock is off performs both functions with Num Lock on.

        REPRODUCIBILITY :
        This bug can be reproduced always.

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

        import java.awt.event.KeyEvent;
        import java.awt.event.KeyListener;
        import javax.swing.JFrame;

        public class TextKeyPadInput extends javax.swing.JPanel implements KeyListener {
            
            public static void main(String args[]) {
                JFrame main = new JFrame("Test Key Input");
                main.add(new TextKeyPadInput());
                main.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                main.pack();
                main.setVisible(true);
            }
            
            public TextKeyPadInput() {
                initComponents();
                jTextField1.addKeyListener(this);
            }
            
            // <editor-fold defaultstate="collapsed" desc="Generated Code">
            private void initComponents() {

                jTextField1 = new javax.swing.JTextField();

                jTextField1.setColumns(10);

                javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
                this.setLayout(layout);
                layout.setHorizontalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(216, Short.MAX_VALUE))
                );
                layout.setVerticalGroup(
                    layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(62, 62, 62)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(219, Short.MAX_VALUE))
                );
            }// </editor-fold>
            
            
            // Variables declaration - do not modify
            private javax.swing.JTextField jTextField1;
            // End of variables declaration

            public void keyTyped(KeyEvent e) {}

            public void keyPressed(KeyEvent e) {
                System.out.println("Key Pressed: " + e.getKeyCode() + ", " + e.getKeyChar() + ", " + KeyEvent.getKeyText(e.getKeyCode()));
            }

            public void keyReleased(KeyEvent e) {}
        }

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

        CUSTOMER SUBMITTED WORKAROUND :
        The only workaround is to have on every text field a key listener that catches those inputs and changes them to what the user desired.

          Activity

          Hide
          yan Yuri Nesterenko (Inactive) added a comment -
          BT2:EVALUATION

          Xsun sniffer should be rewritten after 5 years: new VendorRelease is a big number, thus Xsun cannot be distinguished by it. New sniffer will be behavior-checking. For instance,
          (1) obtain a keycode for XK_KP_7 by XKeysymToKeycode;
          (2) obtain a keysymarray[2] for this keycode by XKeycodeToKeysym
          (3) if it is XK_KP_7, consider this Xsun, for this practical purpose.
          Show
          yan Yuri Nesterenko (Inactive) added a comment - BT2:EVALUATION Xsun sniffer should be rewritten after 5 years: new VendorRelease is a big number, thus Xsun cannot be distinguished by it. New sniffer will be behavior-checking. For instance, (1) obtain a keycode for XK_KP_7 by XKeysymToKeycode; (2) obtain a keysymarray[2] for this keycode by XKeycodeToKeysym (3) if it is XK_KP_7, consider this Xsun, for this practical purpose.

            People

            • Assignee:
              yan Yuri Nesterenko (Inactive)
              Reporter:
              ndcosta Nelson Dcosta
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: