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

KEY_TYPED events come through without modifiers, even if the CTRL key is down.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.2.2_002
    • 1.2.0
    • client-libs
    • b02
    • sparc
    • solaris_2.6



        Name: clC74495 Date: 06/29/99


        On Solaris, KEY_TYPED KeyEvent objects will come through
        without modifiers for many characters, mostly digits and symbols.
        This messes up JTextComponent keymapping pretty badly, because
        extra characters will show up in the text if a command is mapped
        to, say, ctrl-space (set-mark command in EMACS).

        Note: This bug is present in JDK 1.2.2U, which isn't a choice
        on the form.

        A sample follows:
        -----
        package bugsample;

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

        /**
         * This is a sample for a bug I submitted. The description follows:
         *
         * synopsis : KEY_TYPED events come through without modifiers, even if the
         * CTRL key is down.
         *
         * description : On Solaris, KEY_TYPED KeyEvent objects will come through
         * without modifiers for many characters, mostly digits and symbols.
         * This messes up JTextComponent keymapping pretty badly, because
         * extra characters will show up in the text if a command is mapped
         * to, say, ctrl-space (set-mark command in EMACS).
         *
         * Note: This bug is present in JDK 1.2.2U, which isn't a choice
         * on the form.
         *
         * Mike Timbol
         * JBuilder R&D
         * Inprise Corporation
         */
        public class MissingModifiers extends JFrame
        {
          private JLabel instrLabel = new JLabel("Instructions");
          private JLabel test1Label = new JLabel("Instructions");
          private JLabel test2Label = new JLabel("Instructions");
          private JLabel test3Label = new JLabel("Instructions");
          private JLabel sourceLabel = new JLabel("Source:");
          private JTextField sourceField = new JTextField();
          private JButton closeButton = new JButton("Close");

          public MissingModifiers() {
            setTitle("Sample for Solaris missing modifiers bug");

            getContentPane().setLayout(new GridBagLayout());

            getContentPane().add(instrLabel, new GridBagConstraints(0, 0, 3, 1, 1.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 3, 6), 0, 0));
            getContentPane().add(test1Label, new GridBagConstraints(0, 1, 3, 1, 1.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(6, 6, 3, 6), 0, 0));
            getContentPane().add(test2Label, new GridBagConstraints(0, 2, 3, 1, 1.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 6, 3, 6), 0, 0));
            getContentPane().add(test3Label, new GridBagConstraints(0, 3, 3, 1, 1.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 6, 3, 6), 0, 0));

            getContentPane().add(sourceLabel, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 6, 3, 3), 0, 0));
            getContentPane().add(sourceField, new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 3, 3), 0, 0));
            getContentPane().add(closeButton, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
                  ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 6, 6), 0, 0));

            instrLabel.setText("On both Windows NT and Solaris, do the following:");
            test1Label.setText("1. With the <control> key held down, type the following string: \"abcdef\".");
            test2Label.setText("2. With the <control> key held down, type the following string: \"1234-. ?>\".");
            test3Label.setText("The problem with case 2. is that keyTyped events are generated on Solaris, even with the <Ctrl> key down.");

            // Close frame when closeButton is pressed.
            closeButton.addActionListener(
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  setVisible(false);
                  dispose();
                  System.exit(0);
                }
              }
            );

            pack();
          }

          // Create and show frame.
          public static void main(String[] args) {
            MissingModifiers frame = new MissingModifiers();
            frame.setVisible(true);
          }
        }
        (Review ID: 84817)
        ======================================================================

              duke J. Duke
              clucasius Carlos Lucasius (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: