JDK-6270078 : Unexpected preedit text and candidate window are displayed
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt:i18n
  • Affected Version: 5.0u3
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: other
  • Submitted: 2005-05-13
  • Updated: 2013-09-05
  • Resolved: 2005-05-25
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b38Fixed
Related Reports
Relates :  
Relates :  
Description
OPERATING SYSTEM(S)
Windows XP (Japanese)
Windows Server 2003 (Japanese)
FULL JDK VERSION(S):
> java -version
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) Client VM (build 1.5.0_03-b07, mixed mode)
>> java -version
java version "1.5.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_03-b07, mixed mode)
DESCRIPTION:
Windows' preedit window should not display on active component.
Because Java handle preedit string by itself.
But when I tried following operation, Windows' preedit window is displayed.
Test instruction is as follows:
1. Run attached test program (JTextInputTest.java)
2. Check Weekday list window has focus, if not, click Weekday list window
3. Turn Japanese IME, type "nichi" (Floating preedit window is displayed)
4. Move window focus to JTextArea window
5. Turn Japanese IME, type "getsu" and press Space key twice.
   At this moment, unexpected preedit window is displayed on left-top window.
J2SE 64bit version also has this problem but situation is not same.
==============================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DateFormatSymbols;
class JTextInputTest extends JFrame {
  JTextArea text;
  JList list;
  JTextInputTest() {
    setTitle("JTextArea");
    Container c1 = getContentPane();
    c1.setLayout(new GridLayout(1,0));
    text = new JTextArea("Today is ");
    text.setCaretPosition(text.getText().length());
    c1.add(text);
    JFrame f2 = new JFrame("Weekdays");
    Container c2 = f2.getContentPane();
    c2.setLayout(new BorderLayout());
    DateFormatSymbols d = new DateFormatSymbols();
    list = new JList(d.getWeekdays());
    c2.add(list, BorderLayout.CENTER);
    JButton btn = new JButton("Append");
    c2.add(btn, BorderLayout.SOUTH);
    btn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        if (!list.isSelectionEmpty()) {
          text.append(list.getSelectedValue().toString());
        }
      }
    });
    f2.pack();
    setSize(300,300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setVisible(true);
    f2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Point pt = getLocationOnScreen();
    pt.x += getWidth();
    f2.setLocation(pt.x, pt.y);
    f2.setVisible(true);
  }
  public static void main(String[] args) {
    JTextInputTest f = new JTextInputTest();
  }
}
==============================================================

###@###.### 2005-05-13 15:41:48 GMT

Comments
EVALUATION Can be reproducible on both 1.5.0_03 and 1.6 latest build. ###@###.### 2005-05-14 01:43:01 GMT The testcase actually has two different JFrame(s). So they have different InputContext, WInputMethod and even native input method context. When focus is switched from one to another, the current mechanism is to delay the call of endComposition on the InputContext until the focus is transferred to a different component. So no endComposition is called at all. And that causes the old composition window still be active and receives the keybaord input. In Java side, there is no way in this case to call into native side to end the composition since the InputContext and WInputMethod are different and there is no other layer to manage the transition from one InputContext to another InputContext when focus moves. So the only way to solve this is to respond to WM_ACTIVATE message called on the old component and send WM_IME_ENDCOMPOSITION to IME to end the composition for the old component. ###@###.### 2005-05-18 02:14:49 GMT
14-05-2005