<i18n dev> RFR: 8258805: Japanese characters not entered by mouse click on Windows 10

Dmitry Markov dmarkov at openjdk.java.net
Thu Jan 21 21:20:16 UTC 2021

On Thu, 21 Jan 2021 19:25:16 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> I admit I am even more confused now. To me, the description in the comment above is nearly the same as in [JBS comment](https://bugs.openjdk.java.net/browse/JDK-8258805?focusedCommentId=14391025&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14391025). Is the difference that the original test case disabled IME for the middle JTextField whereas in the test case above all JTextField support IME?

Well.. I think the main difference between tests is that the [test attached to the bug](https://bugs.openjdk.java.net/browse/JDK-8258805?focusedCommentId=14391025&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-14391025) uses `JTextField` (Swing) and the [test provided above](https://github.com/openjdk/jdk/pull/2142#issuecomment-763491615) uses `TextField` (AWT). The same input method events are processed differently for Swing and AWT text components. Good example is the following test:

import java.awt.*;
import java.awt.event.*;

public class AWTTextTest1 extends Frame {
    AWTTextTest1() {
        setLayout(new GridLayout(0, 1));
        add(new TextField());
        add(new TextField());
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent we) {
        setSize(400, 300);
    public static void main(String[] args) {
        new AWTTextTest1();

1. Run test (originally it uses `TextField`)
2. Click upper `TextField`, turn on IME, type some character (In case of Japanese, type "aiu") 
3. Click lower `TextField`, the string is canceled. 
4. Replace `TextField` with `JTextField` in the test. Compile and run it again.
5. Click upper `JTextField`, turn on IME, type some character (In case of Japanese, type "aiu")
6. Click lower `JTextField`, the string is committed before focus transition.

> In the updated version of the fix, we always commit the text on any focus change whether the newly focused component supports IME or not.

That’s not quite right. Actually we commit the text if the current IM client is “active client”. For example, `JTextField` is an “active client” but `TextField`  - NOT. The status “active client” depends on the implementation of getInputMethodRequests() method.


PR: https://git.openjdk.java.net/jdk/pull/2142

More information about the i18n-dev mailing list