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

JTable has inputmethod problem in zh locale.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1.6, 1.2.0
    • client-libs

      JDK Version: 1.2beta4-F
      Locale: zh
      OS: Solaris

      We construct a JTable instance and display it in a JFrame. Then, we
      input chars in one line of its cells. There is no problem in inputing
      ENglish chars, we switch the input method to Chinese pinyin, and it also
      has no problem in inputing Chinese, but if we focus on another cell of the
      JTable, it can not accept any input, it is a big problem.
      Following is a short program to reproduce this problem.
      =====================t.java=============================================
      import java.awt.*;
      import java.awt.event.*;
      import java.awt.swing.*;
      import java.awt.swing.table.*;

      public class t {
          public static void main(String []arg) {
              JFrame f;
      f = new JFrame ("test");
      f.getContentPane().setLayout( new BorderLayout());
      f.getContentPane().add("North",new JLabel("Locale:zh, then switch the table cells and input ..."));
      final String[] names = {"First Name", "Last Name", "Tel" };
      final Object[][] data = {
      {"Mike", "Albers", "Soccer"},
      {"Mark", "Andrews", "Baseball"}
      };

      TableModel dataModel = new AbstractTableModel() {
      public int getColumnCount() { return names.length; }
      public int getRowCount() { return data.length;}
      public Object getValueAt(int row, int col) {return data[row][col];}
      public String getColumnName(int column) {return names[column];}
      public Class getColumnClass(int c) {return getValueAt(0, c).getClass();}
      public boolean isCellEditable(int row, int col) {return getColumnClass(col) == String.class;}
      public void setValueAt(Object aValue, int row, int column) { data[row][column] = aValue; }
      };

      JTable tableView = new JTable(dataModel);
      tableView.setFont(new Font("Dialog", Font.PLAIN, 18));
      JScrollPane p = new JScrollPane(tableView);

      //f.getContentPane().add("Center",tableView);
      f.getContentPane().add("Center",p);
              JButton quitButton = new JButton("Quit");
      f.getContentPane().add("South",quitButton);
      quitButton.addActionListener( new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      System.exit(0);
                  }
              });
              f.addWindowListener( new WindowListener() {
      public void windowActivated( WindowEvent e ) {
      }
      public void windowClosed( WindowEvent e ) {
      }
      public void windowClosing( WindowEvent e ) {
      System.exit(0);
      }
      public void windowDeactivated( WindowEvent e ) {
      }
      public void windowDeiconified( WindowEvent e ) {
      }
      public void windowIconified( WindowEvent e ) {
      }
      public void windowOpened( WindowEvent e ) {
      }
      });

      //f.setSize(600,400);
      f.pack();
      f.setVisible(true);
          }
      }
      ===========================================================================
      save this file sa t.java
      javac t.java
      java t
      input in a cell and switch to Chinese input method and input
      some characters, then focus on another cell of the JTable,
      any input can not be accepted by this cell.



      jim.hu@prc 1998-05-19

            sherman Xueming Shen
            jhusunw Jim Hu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: