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

Preedit string still exists after focus change operation

XMLWordPrintable

      FULL PRODUCT VERSION :
      openjdk version " 1.8.0-internal-fastdebug "
      OpenJDK Runtime Environment (build 1.8.0-internal-fastdebug-rank_2013_04_19_11_10-b00)
      OpenJDK Server VM (build 25.0-b28-fastdebug, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Step1: run the testcase, change to microsoft pinyin input method chinese mode.
      Step2: Input some words, leave some words in preedit string not committed.
      Step3: Move focus to the other window, change to English mode and input something
      Step4: Move back to the first window. It is in English mode, but the preedit string is still there(this is the bug).
      Step5: Delete the preedit string with backspace and press enter, it appears again.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Compile and run JTextAreaTest3.java program
      >java JTextAreaTest3 aaa bbb
      2. Two JtextArea windows are opened. Move " bbb " window to right side of " aaa " window
      3. Move focus to " aaa " window.
      4. Select MS-IME in System Input Method. Make it ?hHiragana " input mode (In Chinese system, change to chinese input mode)
      5. Type " a " in JTextArea under MS-IME, IM lookup window appears
      6. Move focus to the second window
      7. Make MS-IME as " alpha numeric " input mode by pressing " Kanji-mode " key. (In Chinese system, change to English input mode)
      8. Move back the focus to the first window
      9. Type " b " , but Japanese " a " is displayed in preedit area with " b " <== Problem
      10. Press Backspace key twice, and press Return key, Japanese " a " is displayed again. (In Chinese system, the chinese word)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      /*
       * Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
       * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       *
       * This code is free software; you can redistribute it and/or modify it
       * under the terms of the GNU General Public License version 2 only, as
       * published by the Free Software Foundation.
       *
       * This code is distributed in the hope that it will be useful, but WITHOUT
       * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
       * version 2 for more details (a copy is included in the LICENSE file that
       * accompanied this code).
       *
       * You should have received a copy of the GNU General Public License version
       * 2 along with this work; if not, write to the Free Software Foundation,
       * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       *
       * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       * or visit www.oracle.com if you need additional information or have any
       * questions.
       */

      /*
       * Portions Copyright (c) 2012 IBM Corporation
       */


      import java.awt.*;
      import javax.swing.*;

      public class JTextAreaTest3 extends JFrame {
          JTextAreaTest3(String title) {
              super(title);
              getContentPane().add(new JTextArea(), BorderLayout.CENTER);
              setSize(300, 300);
              setLocationByPlatform(true);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
          }

          public static void main(String[] args) {
              for (String s : args)
                  new JTextAreaTest3(s);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
        Patch Description:
      Some of Windows IMEs share input context.
      During DBCS input operation, a preedit string is kept in MS-IME and Java also flags as preedit string is exist.
      When a focus is moved to an other window and a preedit string in MS-IME is canceled or committed, Java does not detect this change and still hold the preedit flag.
      This wrong flag causes the problem.
        Fixed code checks preedit string is exist or not at focus back.
      If preedit string is not exist, composition operation is canceled.

            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: