Genau das macht es ja... hier meine Testklasse damit dus siehst -.-
Java Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
| public class SortTest extends JFrame {
private JPanel contentPane;
private JTable table;
private JScrollPane scrollPane;
private JScrollPane scrollPane_1;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SortTest frame = new SortTest();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public SortTest() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
Vector<Element> elements=createElements();
Collections.sort(elements);
Vector<Vector<Object>>data=new Vector<Vector<Object>>();
for(Element e:elements)
{
Vector<Object> v=new Vector<Object>();
v.add(e);
data.add(v);
}
Vector<String>colnames=new Vector<String>();
colnames.add("Element");
table = new JTable(data,colnames);
contentPane.setLayout(new GridLayout(0, 1, 0, 0));
scrollPane = new JScrollPane();
contentPane.add(scrollPane);
JList list = new JList(elements);
scrollPane.setViewportView(list);
scrollPane_1 = new JScrollPane();
contentPane.add(scrollPane_1);
scrollPane_1.setViewportView(table);
}
Vector<Element> createElements()
{
Vector<Element> v=new Vector<Element>();
v.add(new Element(Typ.Avantgade,"Josef"));
v.add(new Element(Typ.Avantgade,"Karl"));
v.add(new Element(Typ.Elegance,"Fritz"));
v.add(new Element(Typ.Elegance,"Hermann"));
v.add(new Element(Typ.Hoch,"Herbert"));
v.add(new Element(Typ.Hoch,"Hermine"));
v.add(new Element(Typ.Tief,"Leopold"));
v.add(new Element(Typ.Tief,"Johann"));
v.add(new Element(Typ.Sport,"Frieda"));
v.add(new Element(Typ.Sport,"Elisabeth"));
return v;
}
} |