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

For Jdk1.4, the table editors for JTable do not work.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P1 P1
    • 1.4.0
    • 1.2.2, 1.4.0
    • client-libs
    • beta2
    • generic, sparc
    • generic, solaris_8
    • Verified

      launch group operation window, you will find the table editors do not work, but on jdk1.2.2-06, they all work well.

      peter.zhang@prc 2001-05-21

      Please see following codes:

      import java.awt.*;
      import java.util.*;
      import javax.swing.*;
      import javax.swing.table.*;
      import javax.swing.event.*;
      import java.awt.event.*;

      public class TestJTblEditing extends JFrame
      {
          public TestJTblEditing()
          {
      MyTable table = new MyTable();
      //table.setColumnSelectionAllowed(false);
              JScrollPane scrollPane = new JScrollPane(table);
      Container c = getContentPane();
              c.setLayout(new BorderLayout());
              c.add(scrollPane, BorderLayout.CENTER);
          }

          static public void main(String[] args) {
              TestJTblEditing spTest = new TestJTblEditing();
      spTest.pack();
      spTest.setVisible(true);
          }
      }

      class MyTable extends JTable {
          public MyTable() {
              int rowCount = 3;
              String[][] data = {{"Click and Edit here"},
      {"Click and Edit here"},
      {"Click and Edit here"}};
              String[] columnNames = {"Editable Column"};
          
              TableModel model = new DefaultTableModel(data, columnNames) {
      public boolean isCellEditable(int rowIndex, int columnIndex) {
      return true;
      }
              };
          
      setModel(model);
          }
          
          public void editingStopped(ChangeEvent e) {
      TableCellEditor editor = getCellEditor();
      Object value = editor.getCellEditorValue();
      setValueAt(value, editingRow, editingColumn);
      System.out.println("editor on row: " + editingRow + " stopped editing");
      super.editingStopped(e);
          }
      }

      run the class on JDk1.2 and JDK1.4, the outputed JTable.editingRow is different, on jdk1.2, it is the edited row, but on Jdk1.4, it is always -1.
      in Sun Management Center, the editingRow is used. so it make SunMC running under JDK1.2 and JDK1.4 has different appearance.

            peterz Peter Zhelezniakov
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: