DefaulTable.java 908 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package ui.view;
  2. import javax.swing.table.DefaultTableModel;
  3. /**
  4. * Default Table.
  5. *
  6. * @author Gruppe14
  7. */
  8. public class DefaulTable extends DefaultTableModel {
  9. private static final long serialVersionUID = 1L;
  10. private boolean[][] editableCells; // 2d array to represent rows and
  11. // columns
  12. /**
  13. * Constructor.
  14. *
  15. * @param rows the Rows
  16. * @param cols the Cols
  17. */
  18. DefaulTable(int rows, int cols) { // constructor
  19. super(rows, cols);
  20. this.editableCells = new boolean[rows][cols];
  21. }
  22. @Override
  23. public boolean isCellEditable(int row, int column) {
  24. return this.editableCells[row][column];
  25. }
  26. /**
  27. * Set Cell Editable.
  28. * @param row the Rows
  29. * @param col the Cols
  30. * @param value true or false
  31. */
  32. public void setCellEditable(int row, int col, boolean value) {
  33. this.editableCells[row][col] = value; // set cell true/false
  34. this.fireTableCellUpdated(row, col);
  35. }
  36. }