DefaulTable.java 688 B

12345678910111213141516171819202122232425
  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) { // custom //
  12. // isCellEditable
  13. // function
  14. return this.editable_cells[row][column];
  15. }
  16. public void setCellEditable(int row, int col, boolean value) {
  17. this.editable_cells[row][col] = value; // set cell true/false
  18. this.fireTableCellUpdated(row, col);
  19. }
  20. }