DefaulTable.java 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package ui.view.main;
  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
  16. * the Rows
  17. * @param cols
  18. * the Cols
  19. */
  20. public DefaulTable(int rows, int cols) { // constructor
  21. super(rows, cols);
  22. this.editableCells = new boolean[rows][cols];
  23. }
  24. @Override
  25. public boolean isCellEditable(int row, int column) {
  26. return this.editableCells[row][column];
  27. }
  28. /**
  29. * Set Cell Editable.
  30. *
  31. * @param row
  32. * the Rows
  33. * @param col
  34. * the Cols
  35. * @param value
  36. * true or false
  37. */
  38. public void setCellEditable(int row, int col, boolean value) {
  39. this.editableCells[row][col] = value; // set cell true/false
  40. this.fireTableCellUpdated(row, col);
  41. }
  42. }