123456789101112131415161718192021222324252627282930313233 |
- package ui.view;
- import javax.swing.table.DefaultTableModel;
- import javax.swing.table.TableCellEditor;
- public class DefaulTable extends DefaultTableModel {
- private boolean[][] editable_cells; // 2d array to represent rows and
- // columns
- DefaulTable(int rows, int cols) { // constructor
- super(rows, cols);
- this.editable_cells = new boolean[rows][cols];
- }
- @Override
- public boolean isCellEditable(int row, int column) {
- return this.editable_cells[row][column];
- }
- public void setCellEditable(int row, int col, boolean value) {
- this.editable_cells[row][col] = value; // set cell true/false
- this.fireTableCellUpdated(row, col);
- }
- // public TableCellEditor getCellEditor(int row, int column) {
- // if (column == 1) {
- // Object value = getValueAt(row, column);
- // if (value != null)
- // return getDefaultEditor(value.getClass());
- // }
- // return super.getCellEditor(row, column);
- // }
- }
|