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