-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumsTableModel.java
More file actions
34 lines (22 loc) · 1.05 KB
/
Copy pathSumsTableModel.java
File metadata and controls
34 lines (22 loc) · 1.05 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
import javax.swing.event.ChangeEvent;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionEvent;
public class SumsTableModel 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
public SumsTableModel(String[][] data, String[] columns) { // constructor
super(data, columns);
this.editable_cells = new boolean[data.length][columns.length];
editable_cells[1][1] = true;
editable_cells[1][2] = true;
editable_cells[1][4] = true;
}
@Override
public boolean isCellEditable(int row, int column) { // custom isCellEditable function
return this.editable_cells[row][column];
}
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
}
}