Guest User

Untitled

a guest
Apr 19th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package crossword;
  6.  
  7. import javax.swing.table.AbstractTableModel;
  8.  
  9. /**
  10. *
  11. * @author arturhebda
  12. */
  13. public class TableModel extends AbstractTableModel {
  14. private Object[][] data;
  15.  
  16. public TableModel() {
  17.  
  18. }
  19.  
  20.  
  21. public TableModel(Object[][] data) {
  22. this.data = data;
  23. }
  24.  
  25. public void setBoard(Board board) {
  26. this.data = board.getBoard();
  27. }
  28.  
  29. @Override
  30. public int getColumnCount() {
  31. return data[0].length;
  32. }
  33.  
  34. @Override
  35. public int getRowCount() {
  36. return data.length;
  37. }
  38.  
  39. @Override
  40. public Object getValueAt(int row, int col) {
  41. return data[row][col];
  42. }
  43.  
  44. @Override
  45. public void setValueAt(Object value, int row, int col) {
  46. data[row][col] = value;
  47. fireTableCellUpdated(row, col);
  48. }
  49. }
Add Comment
Please, Sign In to add comment