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

[Win] InputContext.setCompositionEnabled(true) doesn't work for Korean on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.4.2
    • client-libs

      Name: rmT116609 Date: 04/22/2004


      FULL PRODUCT VERSION :
      java version "1.4.1_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_05-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_05-b01, mixed mode)

      java version "1.4.2_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
      Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]
      Also reported for other versions by our Korean customers.

      A DESCRIPTION OF THE PROBLEM :
      We use getInputContext().setCompositionEnabled(true) to satisfy requirements for text fields to automatically start with the IME enabled. On Windows, this works for Chinese and Japanese input, but does not work for Korean.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Install Korean support and switch system locale to Korean.
      Ensure current input method is Korean.

      TextArea test = new TextArea();
      ...
      test.getInputContext().setCompositionEnabled(true);

      Type into the TextArea.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Korean characters should start being composed.
      ACTUAL -
      ASCII characters appear. The IME had to be enabled manually to get Korean input.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No Exception thrown (would expect one if operation was unsupported).

      BTW, I also tried 1.5.0-beta1, and the bug is not fixed there.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // Java imports
      import java.applet.Applet;
      import java.awt.Component;
      import java.awt.TextField;
      import java.awt.event.FocusEvent;
      import java.awt.event.FocusListener;
      import java.awt.event.KeyEvent;
      import java.awt.im.InputContext;
      import java.util.Locale;

      public class IMETest extends Applet implements FocusListener {
        TextField _japanese;
        TextField _korean;
        TextField _english;

        private static final Class[] INTEGER_ARG = { Integer.TYPE };

        public void init()
        {
          _japanese = new TextField(20);
          _korean = new TextField(20);
          _english = new TextField(20);

          _japanese.addFocusListener(this);
          _korean.addFocusListener(this);
          _english.addFocusListener(this);

          add(_japanese);
          add(_korean);
          add(_english);

          _japanese.setBounds(10,70,200,20);
          _korean.setBounds(10,100,200,20);
          _english.setBounds(10,130,200,20);

          _japanese.setVisible(true);
          _korean.setVisible(true);
          _english.setVisible(true);
        }

        public void start()
        {
        }

        private boolean composeInLocale(Locale l)
        {
          return (l.getLanguage() == Locale.JAPANESE.getLanguage()
                  || l.getLanguage() == Locale.KOREAN.getLanguage()
                  || l.getLanguage() == Locale.CHINESE.getLanguage()
                  || l.getLanguage() == Locale.SIMPLIFIED_CHINESE.getLanguage()
                  || l.getLanguage() == Locale.TRADITIONAL_CHINESE.getLanguage());
        }


        // Implementation of java.awt.event.FocusListener

        public void focusGained(FocusEvent focusEvent)
        {
          System.out.println("Processing focus gained...");
          Locale newLocale = null;
          Component input = focusEvent.getComponent();

          if (input == _japanese)
            newLocale = Locale.JAPANESE;
          else if (input == _korean)
            newLocale = Locale.KOREAN;
          else if (input == _english)
            newLocale = Locale.ENGLISH;

          try {
            if (newLocale == null)
              System.out.println("Focus change; no locale change");
            else {
              InputContext ctx = input.getInputContext();
              ctx.selectInputMethod(newLocale);
              boolean enable = composeInLocale(newLocale);
              ctx.setCompositionEnabled(enable);
              boolean enabled = ctx.isCompositionEnabled();
              if (enable && enabled)
                System.out.println("IME Enabled");
              else if (enable) {
                System.out.println("Tried to enable, but failed");
              }
            }
          }
          catch (Throwable e) {
            System.out.println("Can't switch Input Methods: " + e.toString());
          }
        }

        public void focusLost(FocusEvent focusEvent)
        {
        }
      }

      ---------- END SOURCE ----------
      (Incident Review ID: 231316)
      ======================================================================
      ###@###.### 10/24/04 22:38 GMT

            nishjain Nishit Jain
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: