DefaulTable.java 617 B

123456789101112131415161718192021222324
  1. package ui.view;
  2. import javax.swing.table.DefaultTableModel;
  3. public class DefaulTable extends DefaultTableModel {
  4. private boolean[][] editable_cells; // 2d array to represent rows and
  5. // columns
  6. DefaulTable(int rows, int cols) { // constructor
  7. super(rows, cols);
  8. this.editable_cells = new boolean[rows][cols];
  9. }
  10. @Override
  11. public boolean isCellEditable(int row, int column) {
  12. return this.editable_cells[row][column];
  13. }
  14. public void setCellEditable(int row, int col, boolean value) {
  15. this.editable_cells[row][col] = value; // set cell true/false
  16. this.fireTableCellUpdated(row, col);
  17. }
  18. }