2
* To change this template, choose Tools | Templates
3
* and open the template in the editor.
5
package net.sf.goodgame.client.user.userinfo;
7
import java.util.LinkedHashSet;
10
import java.util.Vector;
11
import javax.swing.JComponent;
12
import javax.swing.JList;
13
import javax.swing.JTabbedPane;
14
import net.sf.goodgame.shared.UserInfoElement;
20
public class UserInfoGUI {
22
private final String username;
23
private Set<UserInfoElement> elements;
24
private JTabbedPane root;
25
private JList userSupplied;
26
private JList gameResults;
28
public UserInfoGUI(String username, List<UserInfoElement> elements) {
29
this.username = username;
30
this.elements = new LinkedHashSet<UserInfoElement>();
31
userSupplied = new JList();
32
userSupplied.setCellRenderer(new UserInfoListCellRenderer());
33
gameResults = new JList();
34
gameResults.setCellRenderer(new UserInfoListCellRenderer());
35
root = new JTabbedPane();
36
root.addTab("User Supplied", userSupplied);
37
root.addTab("Game Results", gameResults);
38
setElements(elements);
41
public JComponent getComponent() {
45
public void setElements(List<UserInfoElement> newElements) {
46
elements.removeAll(newElements);
47
elements.addAll(newElements); //Replace the old elements with the new.
48
Vector<UserInfoElement> gameResultsElements = new Vector<UserInfoElement>(elements.size());
49
Vector<UserInfoElement> userSuppliedElements = new Vector<UserInfoElement>(elements.size());
50
for (UserInfoElement element : elements) {
51
switch (element.getType()) {
53
System.out.println("User Supplied: "+element);
54
userSuppliedElements.add(element);
57
System.out.println("Game Result: "+element);
58
gameResultsElements.add(element);
61
System.out.println("Unknown UserInfoType: " + element.getType());
65
userSupplied.setListData(userSuppliedElements);
66
gameResults.setListData(gameResultsElements);
69
public String getUsername() {