Source code: evt/gui/JspmEvtTableModel.java
1 package evt.gui;
2
3 import java.awt.*;
4 import javax.swing.table.*;
5
6 class JspmEvtTableModel extends AbstractTableModel
7 {
8 final String[] columnNames = {"#", "Sev", "Node", "Source", "Time", "Event" };
9
10 final Object[][] data = {};
11
12 public int getColumnCount() {
13 return columnNames.length;
14 }
15
16 public int getRowCount() {
17 return data.length;
18 }
19
20 public String getColumnName(int col) {
21 return columnNames[col];
22 }
23
24 public Object getValueAt(int row, int col) {
25 return data[row][col];
26 }
27
28 /*
29 * Don't need to implement this method unless your table's
30 * data can change.
31 */
32 public void setValueAt(Object value, int row, int col) {
33 if (data[0][col] instanceof Integer && !(value instanceof Integer)) {
34
35 //With JFC/Swing 1.1 and JDK 1.2, we need to create
36 //an Integer from the value; otherwise, the column
37 //switches to contain Strings. Starting with v 1.3,
38 //the table automatically converts value to an Integer,
39 //so you only need the code in the 'else' part of this
40 //'if' block.
41 //XXX: See TableEditDemo.java for a better solution!!!
42
43 try {
44 data[row][col] = new Integer(value.toString());
45 fireTableCellUpdated(row, col);
46 } catch (NumberFormatException e) {
47 }
48 } else {
49 data[row][col] = value;
50 fireTableCellUpdated(row, col);
51 }
52 }
53
54 /*
55 * Don't need to implement this method unless your table's
56 * editable.
57 */
58 public boolean isCellEditable(int row, int col) {
59 //Note that the data/cell address is constant,
60 //no matter where the cell appears onscreen.
61 return false;
62 /* if (col < 2) {
63 return false;
64 } else {
65 return true;
66 }*/
67 }
68
69 }
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98