source: src/main/java/genius/gui/progress/ProgressInfo.java@ 345

Last change on this file since 345 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.7 KB
Line 
1package genius.gui.progress;
2
3import javax.swing.table.AbstractTableModel;
4
5class ProgressInfo extends AbstractTableModel{
6
7 private static final long serialVersionUID = 7091049252211861744L;
8 private static final int NUMBER_OF_COLUMNS = 8;
9 private String[] colNames={"Round","Side","utilA","utilB","utilA discount","utilB discount", "Time"};
10 private Object[][] data;
11
12 public ProgressInfo()
13 {
14 super();
15 data = new Object [NUMBER_OF_COLUMNS][colNames.length];
16 }
17
18 public void addRow(){
19 int currentLength = data.length;
20 Object [][] temp = new Object [currentLength+1][colNames.length];
21 //System.out.println("temp length "+temp.length);
22 for(int j=0;j<temp.length-1;j++){
23 for(int i=0;i<colNames.length;i++){
24 temp [j][i] = data [j][i];
25 //System.out.println("temp data "+temp [j][i]);
26 }
27 }
28 data = temp;
29 fireTableDataChanged();
30 }
31
32 public void reset()
33 {
34// System.out.println("reset the JTable now.");
35 data = new Object [NUMBER_OF_COLUMNS][colNames.length];
36 fireTableDataChanged();
37 }
38
39 public int getColumnCount() {
40 return colNames.length;
41 }
42
43 public int getRowCount() {
44 return data.length;
45 }
46
47 public String getColumnName(int col) {
48 return colNames[col];
49 }
50
51 public Object getValueAt(int row, int col) {
52 Object result = null;
53 try {
54 result = data[row][col];
55 } catch (Exception e) { }
56 return result;
57 }
58
59 public void setValueAt(Object value, int row, int col) {
60 data[row][col] = value;
61 //Notify all listeners that the value of the cell at (row, column) has been updated
62 fireTableCellUpdated(row, col);
63 }
64
65}
Note: See TracBrowser for help on using the repository browser.