-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrarGridViewTableModel.java
More file actions
51 lines (38 loc) · 1.52 KB
/
Copy pathOrarGridViewTableModel.java
File metadata and controls
51 lines (38 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import javax.swing.table.DefaultTableModel;
public class OrarGridViewTableModel extends DefaultTableModel {
//https://stackoverflow.com/questions/12776021/how-to-make-jtable-cell-editable-noneditable-dynamically
private boolean[][] editable_cells; // 2d array to represent rows and columns
private int editedRow;
private int editedColumn;
public OrarGridViewTableModel(String[][] data, String[] columns) { // constructor
super(data, columns);
this.editable_cells = new boolean[data.length][columns.length];
}
@Override
public boolean isCellEditable(int row, int column) { // custom isCellEditable function
//return this.editable_cells[row][column];
return false;
}
public boolean getEditRights(int row, int column) { // custom isCellEditable function
return this.editable_cells[row][column];
}
@Override
public void setValueAt(Object value, int row, int col) {
super.setValueAt(value, row, col);
editedRow = row;
editedColumn = col;
}
public void setCellEditable(int row, int col, boolean value) {
this.editable_cells[row][col] = value; // set cell true/false
//this.fireTableCellUpdated(row, col);//ha ezt kiszedem mukodik. nagyon szegyellem magam
}
public int getEditedRow() {
return editedRow;
}
public int getEditedColumn() {
return editedColumn;
}
public void setEditable_cells(boolean[][] editable_cells) {
this.editable_cells = editable_cells;
}
}