我在java中使用JTable,但它不允许我编辑单元格.
private final TableModel dataModel = new AbstractTableModel() {
        public int getColumnCount() { 
            return 5; 
        }
        public int getRowCount() { 
            return 10;
        }
        public Object getValueAt(int row, int col) { 
            return new Integer(row*col); 
        }
};
private final JTable table = new JTable(dataModel);
添加以下代码
 public boolean isCellEditable(int row, int col)
      { return true; }
 public void setValueAt(Object value, int row, int col) {
    rowData[row][col] = value;
    fireTableCellUpdated(row, col);
  }
你应该有一个数组,你将保存更改
| 归档时间: | 
 | 
| 查看次数: | 23140 次 | 
| 最近记录: |