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

JTextComponents return wrong values for InputMethodRequests.getInsertPositionOff

XMLWordPrintable

    • beta2
    • generic
    • generic

      The implementation of java.awt.im.InputMethodRequests.getInsertPositionOffset in the Swing text components returns wrong values. The returned value apparently is increased for composed characters, while the specification says that the method returns the insert position in the *committed* text.

      To see the values, modify test/java/awt/im/CityInputMethod/CityInputMethod.java. After
      inputMethodContext.dispatchInputMethodEvent(
                                        InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
      as.getIterator(),
      committedCharacterCount,
      caret,
      null);
      add the statement
      System.out.println("committedCharacterCount: "
      + committedCharacterCount + ", getInsertPositionOffset: "
      + inputMethodContext.getInsertPositionOffset());
      Build the input method and install it into your Java runtime. Run Stylepad, click into the text field to get an insertion point, select CityInputMethod, start typing some characters. You'll see that the value returned by getInsertPositionOffset increases even though only composed text is added.

            naoto Naoto Sato
            nlindenbsunw Norbert Lindenberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: