1 |
mojays |
2 |
package appl.parallel.gui; |
2 |
|
|
|
3 |
|
|
import java.util.Enumeration; |
4 |
|
|
import java.util.Properties; |
5 |
|
|
|
6 |
|
|
import javax.swing.JTable; |
7 |
|
|
import javax.swing.table.DefaultTableModel; |
8 |
|
|
|
9 |
|
|
/** |
10 |
|
|
* Just a simple 2 column Property Table |
11 |
|
|
* |
12 |
|
|
* @author Dominik Appl |
13 |
|
|
*/ |
14 |
|
|
public class SimplePropertyTable extends JTable { |
15 |
|
|
|
16 |
|
|
private final String colname1; |
17 |
|
|
|
18 |
|
|
private final String colname2; |
19 |
|
|
|
20 |
|
|
public SimplePropertyTable(String colname1, String colname2) { |
21 |
|
|
super(1, 2); |
22 |
|
|
this.colname1 = colname1; |
23 |
|
|
this.colname2 = colname2; |
24 |
|
|
|
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
public SimplePropertyTable() { |
28 |
|
|
this("Property", "Value"); |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
public void setPropertyData(Properties propdata) { |
32 |
|
|
Enumeration keys = propdata.keys(); |
33 |
|
|
// Create array |
34 |
|
|
String[][] data = new String[propdata.size()][2]; |
35 |
|
|
int i = 0; |
36 |
|
|
while (keys.hasMoreElements()) { |
37 |
|
|
data[i][0] = (String) keys.nextElement(); |
38 |
|
|
data[i][1] = (String) propdata.getProperty(data[i][0]); |
39 |
|
|
i++; |
40 |
|
|
} |
41 |
|
|
setModel(new DefaultTableModel(data, |
42 |
|
|
new String[] { colname1, colname2 })); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
} |