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

Regression : Cannot use IME on JComboBox Japanese

    XMLWordPrintable

Details

    • b55
    • 7
    • b142
    • x86
    • windows
    • Verified

    Description

      SYNOPSIS
      --------
      Cannot use IME on JComboBox

      OPERATING SYSTEMS
      -----------------
      Windows XP SP3 x86 (Japanese)
      Windows Server 2008 R2 Enterprise SP1 (Japanese)
      Not Reproducible using JDK 7 b130 on Linux
      Not Reproducible using 1.6.0_24-b07 on Windows


      FULL JDK VERSION
      ----------------
      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b130)
      Java HotSpot(TM) Client VM (build 21.0-b02, mixed mode)

      DESCRIPTION
      -----------
      On Windows platform, we cannot use IME on JComboBox after opening drop-down list. I applied KeyListener against JComboBox, it should work. Works fine with JDK 7 b130 on Linux, and 1.6.0_24-b07 on Windows

      REPRODUCTION INSTRUCTIONS
      -------------------------
      This testing requires Japanese Windows

      1. Compile and run JComboBoxTest2.java from Command Prompt
         > javac JComboBoxTest2.java
         > java JComboBoxTest2
      2. Turn on IME, type "ma", Japanese "MA" is displayed on preedit area
      3. Press Return key to commit
      4. Japanese "MAMIMUMEMO" is displayed on JComboBox
      5. Open drop-down list on JComboBox
      6. Check IME status. If IME is turned off, please turn it on
         (If it's turned off, it may not be turned on)
      7. If IME is on, type "wa", Japanese "WA" should be displayed on preedit
         area, but "wa" is displayed in Command Prompt

      TESTCASE SOURCE
      ---------------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      class JComboBoxTest2 extends JFrame implements ActionListener {
          MyComboBox cb = null;
          JButton btn = null;
          static String[] data = new String[] {
              "\u3042\u3044\u3046\u3048\u304a", "\u304b\u304d\u304f\u3051\u3053",
              "\u3055\u3057\u3059\u305b\u305d", "\u305f\u3061\u3064\u3066\u3068",
              "\u306a\u306b\u306c\u306d\u306e", "\u306f\u3072\u3075\u3078\u307b",
              "\u307e\u307f\u3080\u3081\u3082", "\u3084\u3086\u3088",
              "\u3089\u308a\u308b\u308c\u308d", "\u308f\u3092\u3093",
          };

          JComboBoxTest2 () {
              setTitle("JComboBoxTest2");
              Container c = getContentPane();
              c.setLayout(new GridLayout(0,1));
              cb = new MyComboBox(data);
              c.add(cb);
              btn = new JButton("Print");
              btn.addActionListener(this);
              c.add(btn);
              pack();
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setLocationRelativeTo(null);
              setVisible(true);
          }
          public void actionPerformed(ActionEvent ae) {
              System.out.println(cb.getSelectedItem().toString());
              cb.requestFocus();
          }
          public static void main(String[] args) {
              new JComboBoxTest2();
          }

          class MyComboBox extends JComboBox implements KeyListener, JComboBox.KeySelectionManager {
              private long accessTime;
              private StringBuffer sb = new StringBuffer();
              MyComboBox(String[] s){
                  super(s);
                  setKeySelectionManager(this);
                  addKeyListener(this);
              }
              public int selectionForKey(char aKey, ComboBoxModel aModel) { return -1; }
              public void keyPressed(KeyEvent event) { }
              public void keyTyped(KeyEvent event) {
                  char c = event.getKeyChar();
                  if ((accessTime + 800) < System.currentTimeMillis()) {
                      sb = new StringBuffer();
                  }
                  sb.append(c);
                  accessTime = System.currentTimeMillis();
                  String lower = sb.toString().toLowerCase();
                  System.out.println("Search String: " + lower);
                  for(int i=0; i<getItemCount(); i++) {
                      if(((String)getItemAt(i)).toLowerCase().startsWith(lower)) {
                          setSelectedIndex(i);
                          break;
                      }
                  }
              }
              public void keyReleased(KeyEvent event) { }
          }
      }

      Attachments

        Issue Links

          Activity

            People

              dcherepanov Dmitry Cherepanov
              dkorbel David Korbel (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: