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

JComboBox's search function cannot handle MBCS character

XMLWordPrintable

      Name: dk106046 Date: 07/17/2003

      OPERATING SYSTEM(S):
      --------------------
      Redhat 7.3 with Japanese environment

      FULL JDK VERSION(S):
      -------------------
      java version "1.4.1_03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_03-b02)
      Java HotSpot(TM) Client VM (build 1.4.1_03-b02, mixed mode)

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


      ------------
      JComboBox's list has search function but it cannot accept Japanese character.
      JList has same function, it can accept Japanese character.
      JComboBox's list should accept Japanese character.

      Test instruction is as follows:
       1. Compile JComboBoxTest.java and JListTest.java and run them with Japanese environment
       2. Press Shift+Space to activate Japanese IME(kinput2) on JComboBox window
       3. Move JComboBoxTest window to center side
       4. Click JComboBox to display dropdown list
       5. Press "1" and Return key, but list is not moved <=== PROBLEM
       6. Press Shift+Space to deactivate Japanese IME on JComboBox window
       7. Press "1" and Return key, list is moved
       8. Press Shift+Space to activate Japanese IME(kinput2) on JList window
       9. Click JList window to change focus
      10. Press "1" and Return key, list is moved
      11. Press Shift+Space to deactivate Japanese IME on JList window
      12. Press "1" and Return key, list is moved

      ================================================================
      /*
       * JComboBoxTest.java
       */
      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;
      import java.text.DateFormatSymbols;
      import java.util.ResourceBundle;

      public class JComboBoxTest extends JFrame implements KeyListener {
          public JComboBoxTest() {
              setTitle("JComboBox Test");
              JComboBox combo = new JComboBox();
              try {
                  ResourceBundle r = ResourceBundle.getBundle ("JComboBoxTest");
                  for (int i = 0; true ; i++) {
                      try {
                          combo.addItem(r.getString ("combobox." + i));
                      } catch (java.util.MissingResourceException e) {
                          break;
                      }
                  }
              } catch (java.util.MissingResourceException e) {
                  DateFormatSymbols d = new DateFormatSymbols();
                  String[] months = d.getMonths();
                  for (int i = 0; i < months.length ; i++) {
                      if (months[i].equals("")) continue;
                      combo.addItem(months[i]);
                  }
                  String[] weekdays = d.getWeekdays();
                  for (int i = 0; i < weekdays.length ; i++) {
                      if (weekdays[i].equals("")) continue;
                      combo.addItem(weekdays[i]);
                  }
              }
              combo.addKeyListener(this);
              Container c = getContentPane();
              c.setLayout(new BorderLayout());
              c.add(combo, BorderLayout.CENTER);
          }
          public void keyTyped(KeyEvent event) {
              char c = event.getKeyChar();
              System.out.println("keyTyped => " + c + " (0x" + Integer.toHexString((int)c) + ")");
          }
          public void keyPressed(KeyEvent event) {
              int code = event.getKeyCode();
              String text = event.getKeyText(code);
              char c = event.getKeyChar();
              System.out.println("keyPressed => " + c + "[" + text + "] (" + code + ")");
          }
          public void keyReleased(KeyEvent event) {
              char c = event.getKeyChar();
              System.out.println("keyTyped => " + c + " (0x" + Integer.toHexString((int)c) + ")");
          }
          public static void main(String[] args) {
              JComboBoxTest f = new JComboBoxTest();
              f.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent event) {
                      System.exit(0);
                  }
              });
              f.pack();
              f.show();
          }
      }
      ================================================================
      /*
       * JListTest.java
       */
      import java.awt.*;
      import javax.swing.*;
      import java.awt.event.*;
      import java.text.DateFormatSymbols;
      import java.util.ResourceBundle;
      import java.util.Vector;

      public class JListTest extends JFrame implements KeyListener {
          public JListTest() {
              setTitle("JList Test");
              JList list = new JList();
              Vector listItem = new Vector();
              try {
                  ResourceBundle r = ResourceBundle.getBundle ("JListTest");
                  for (int i = 0; true ; i++) {
                      try {
                          listItem.addElement(r.getString ("combobox." + i));
                      } catch (java.util.MissingResourceException e) {
                          break;
                      }
                  }
              } catch (java.util.MissingResourceException e) {
                  DateFormatSymbols d = new DateFormatSymbols();
                  String[] months = d.getMonths();
                  for (int i = 0; i < months.length ; i++) {
                      if (months[i].equals("")) continue;
                      listItem.addElement(months[i]);
                  }
                  String[] weekdays = d.getWeekdays();
                  for (int i = 0; i < weekdays.length ; i++) {
                      if (weekdays[i].equals("")) continue;
                      listItem.addElement(weekdays[i]);
                  }
              }
              list.setListData(listItem);
              list.addKeyListener(this);
              Container c = getContentPane();
              c.setLayout(new BorderLayout());
              c.add(list, BorderLayout.CENTER);
          }
          public void keyTyped(KeyEvent event) {
              char c = event.getKeyChar();
              System.out.println("keyTyped => " + c + " (0x" + Integer.toHexString((int)c) + ")");
          }
          public void keyPressed(KeyEvent event) {
              int code = event.getKeyCode();
              String text = event.getKeyText(code);
              char c = event.getKeyChar();
              System.out.println("keyPressed => " + c + "[" + text + "] (" + code + ")");
          }
          public void keyReleased(KeyEvent event) {
              char c = event.getKeyChar();
              System.out.println("keyTyped => " + c + " (0x" + Integer.toHexString((int)c) + ")");
          }
          public static void main(String[] args) {
              JListTest f = new JListTest();
              f.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent event) {
                      System.exit(0);
                  }
              });
              f.pack();
              f.show();
          }
      }
      ================================================================

      ======================================================================

            Unassigned Unassigned
            dkorbel David Korbel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: