DefaulTable.java 919 B

123456789101112131415161718192021222324252627282930313233
  1. package ui.view;
  2. import javax.swing.table.DefaultTableModel;
  3. import javax.swing.table.TableCellEditor;
  4. public class DefaulTable extends DefaultTableModel {
  5. private boolean[][] editable_cells; // 2d array to represent rows and
  6. // columns
  7. DefaulTable(int rows, int cols) { // constructor
  8. super(rows, cols);
  9. this.editable_cells = new boolean[rows][cols];
  10. }
  11. @Override
  12. public boolean isCellEditable(int row, int column) {
  13. return this.editable_cells[row][column];
  14. }
  15. public void setCellEditable(int row, int col, boolean value) {
  16. this.editable_cells[row][col] = value; // set cell true/false
  17. this.fireTableCellUpdated(row, col);
  18. }
  19. // public TableCellEditor getCellEditor(int row, int column) {
  20. // if (column == 1) {
  21. // Object value = getValueAt(row, column);
  22. // if (value != null)
  23. // return getDefaultEditor(value.getClass());
  24. // }
  25. // return super.getCellEditor(row, column);
  26. // }
  27. }