source: src/main/java/genius/gui/progress/NegoTableModel.java@ 209

Last change on this file since 209 was 127, checked in by Wouter Pasman, 6 years ago

#41 ROLL BACK of rev.126 . So this version is equal to rev. 125

File size: 1.4 KB
Line 
1package genius.gui.progress;
2
3import javax.swing.table.AbstractTableModel;
4
5/**
6 * Table model to hold generic table data for display.
7 *
8 */
9public class NegoTableModel extends AbstractTableModel {
10
11 private static final long serialVersionUID = 2854132547932201984L;
12 private String[] colNames;
13 private Object[][] data; // data[row][col]
14
15 public NegoTableModel(String[] colNames) {
16 super();
17 this.colNames = colNames;
18 data = new Object[6][colNames.length];
19 }
20
21 public void addRow() {
22 int currentLength = data.length;
23 Object[][] temp = new Object[currentLength + 1][colNames.length];
24 // System.out.println("temp length "+temp.length);
25 for (int j = 0; j < temp.length - 1; j++) {
26 for (int i = 0; i < colNames.length; i++) {
27 temp[j][i] = data[j][i];
28 // System.out.println("temp data "+temp [j][i]);
29 }
30 }
31 data = temp;
32 fireTableDataChanged();
33 }
34
35 public int getColumnCount() {
36 return colNames.length;
37 }
38
39 public int getRowCount() {
40 return data.length;
41 }
42
43 public String getColumnName(int col) {
44 return colNames[col];
45 }
46
47 public Object getValueAt(int row, int col) {
48 return data[row][col];
49 }
50
51 public void setValueAt(Object value, int row, int col) {
52 data[row][col] = value;
53 // Notify all listeners that the value of the cell at (row, column) has
54 // been updated
55 fireTableCellUpdated(row, col);
56 }
57
58}
Note: See TracBrowser for help on using the repository browser.