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

inputMethodTextChanged(), caretPositionChanged() not invoked

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 5.0
    • client-libs

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

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      Typing on a US-english 101-key keyboard _is_ an input-method, right? That being so, typing a key on said keyboard should cause InputMethodEvents. You don't really expect us to write code treating that as a special case?!

      Using KeyListener is not at all appropriate ... I want to deal with textual changes. I don't want to have to track the state of the text by interpreting what a SHIFT+LEFT_ARROW, SHIFT+LEFT_ARROW, BACKSPACE sequence actually does.

      You've gone to the trouble of designing this nice InputMethod API that encapsulates the desired functionality. Why can't we use it?

      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4474633

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test program in a debugger, and type into the JTexfField. Set debug points on the inputMethodTextChanged and caretPositionChanged.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      As each key is pressed, InputMethodEvent objects are sent to System.out. The debug points are triggered.
      ACTUAL -
      Nothing is printed. No debug points are triggered.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.InputMethodEvent;
      import java.awt.event.InputMethodListener;


      public class InputMethodTester extends JPanel {

          private JTextField input;

          public InputMethodTester() {

              super(new BorderLayout());

              this.input = new JTextField("");
              this.input.setPreferredSize(new Dimension(200,20));
              add(this.input, BorderLayout.CENTER);

              this.input.addInputMethodListener(new InputMethodListener() {
                  // grr. http://developer.java.sun.com/developer/bugParade/bugs/4474633.html
                  // grr. http://developer.java.sun.com/developer/bugParade/bugs/4395801.html
                  public void inputMethodTextChanged(InputMethodEvent event) {
                      System.out.println(event.toString());
                  }

                  public void caretPositionChanged(InputMethodEvent event) {
                      System.out.println(event.toString());
                  }
              });

          }

          public static void main(String[] args) {
              InputMethodTester2 tester = new InputMethodTester2();
              JFrame frame = new JFrame("Input Method Tester");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.add(tester);
              frame.pack();
              frame.setVisible(true);
          }

      }
      ---------- END SOURCE ----------

            xlu Xiaobin Lu (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: