1 |
package appl.util; |
2 |
|
3 |
import javax.swing.table.DefaultTableModel; |
4 |
import javax.swing.table.TableModel; |
5 |
|
6 |
/** |
7 |
* Simple {@link TableModel} that allows to specify columns which are not editable |
8 |
* |
9 |
* @author Dominik Appl |
10 |
*/ |
11 |
public class NonEditableTableModel extends DefaultTableModel { |
12 |
private final boolean[] isEditable; |
13 |
|
14 |
/** |
15 |
* @param columnNames |
16 |
* <code>array</code> containing the names of the new columns; |
17 |
* if this is <code>null</code> then the model has no columns |
18 |
* |
19 |
* @param isEditable Specifies for each column if editable or not |
20 |
* |
21 |
* @param rowCount |
22 |
* the number of rows the table holds |
23 |
*/ |
24 |
public NonEditableTableModel(Object[] columnNames, boolean[] isEditable, |
25 |
int rowCount) { |
26 |
super(columnNames, rowCount); |
27 |
this.isEditable = isEditable; |
28 |
} |
29 |
|
30 |
@Override |
31 |
public boolean isCellEditable(int row, int column) { |
32 |
return isEditable[column]; |
33 |
} |
34 |
|
35 |
} |