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

No keyPressed event for Compose key

XMLWordPrintable

    • Fix Understood
    • sparc
    • solaris_7

      Only getting keyReleased events for the compose key, not keypressed under
      hopper build 8. xev gives me both. Same bug occurs with 1.3.1 and 1.4.


      params= KEY_RELEASED,keyCode=65312,Compose ,keyLocation=KEY_LOCATION_STANDARD
      KeyChar: ? = 65535 KeyCode: 65312 Modifiers: 0
      keyText= Compose


      params= KEY_RELEASED,keyCode=65312,Compose ,keyLocation=KEY_LOCATION_STANDARD
      KeyChar: ? = 65535 KeyCode: 65312 Modifiers: 0
      keyText= Compose


      params= KEY_RELEASED,keyCode=65312,Compose ,keyLocation=KEY_LOCATION_STANDARD
      KeyChar: ? = 65535 KeyCode: 65312 Modifiers: 0
      keyText= Compose


      params= KEY_RELEASED,keyCode=65312,Compose ,keyLocation=KEY_LOCATION_STANDARD
      KeyChar: ? = 65535 KeyCode: 65312 Modifiers: 0
      keyText= Compose




      echawkes@gradgrind:/home/echawkes/tests/4115484( 146 )% cat MySwingTest.java
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class MySwingTest extends JApplet implements KeyListener, ActionListener {

          JTextField jtf = null;

          public static void main(String[] args) {
              JFrame frame = new JFrame("MySwingTest");
              JPanel p = new JPanel();

              MySwingTest applet = new MySwingTest();
              applet.init();

              p.add("Center", applet);
              frame.getContentPane().add(p);

              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              frame.setSize(450, 200);
              frame.setVisible(true);

              applet.start();
          }

          public void init() {
              JLabel jl = new JLabel("Enter characters");

              jtf = new JTextField("Hello World", 20);
              jtf.addKeyListener(this);
              jtf.addActionListener(this);

              // the default layout manager for a JApplet is a BorderLayout
              this.getContentPane().setLayout(new FlowLayout());
              this.getContentPane().add(jl, FlowLayout.LEFT);
              this.getContentPane().add(jtf, FlowLayout.CENTER);
          }

          public void start() {
              jtf.requestFocus();
          }

          public void keyPressed(KeyEvent evt)
          {
              printKey(evt);
          }

          public void keyTyped(KeyEvent evt)
          {
              printKey(evt);
          }

          public void keyReleased(KeyEvent evt)
          {
              printKey(evt);
              System.out.print("\n");
          }

          public void actionPerformed(ActionEvent evt)
          {
              System.out.print("\n");
              System.out.print("Action Event\n");
              System.out.println(evt.toString());
              System.out.print("\n");
          }

          protected void printKey(KeyEvent evt)
          {
              switch(evt.getID())
              {
                case KeyEvent.KEY_TYPED:
                  break;
                case KeyEvent.KEY_PRESSED:
                  break;
                case KeyEvent.KEY_RELEASED:
                  break;
                default:
                  System.out.println("Other Event ");
                  return;
              }

              System.out.print("params= " + evt.paramString() + " \n" +
                "KeyChar: " + evt.getKeyChar() + " = " + (int) evt.getKeyChar() +
                " KeyCode: " + evt.getKeyCode() +
                " Modifiers: " + evt.getModifiers());
              if (evt.isActionKey())
                  System.out.print(" Action Key");
              System.out.print("\n");

              System.out.println("keyText= " + evt.getKeyText(evt.getKeyCode())
                + "\n");
          }

      }

            yan Yuri Nesterenko
            ehawkessunw Eric Hawkes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: