summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/GameListPanel.java
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2011-06-14 17:57:19 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2011-06-14 17:57:19 +0200
commitc84bebceb7690410c33ae15f61ca2e01c79342b8 (patch)
treebab7fd801accc0299605422ed523cea3e1bc4206 /src/jrummikub/view/impl/GameListPanel.java
parent99c3d48f1021e59d8db0873ae9b626594954e44f (diff)
downloadJRummikub-c84bebceb7690410c33ae15f61ca2e01c79342b8.tar
JRummikub-c84bebceb7690410c33ae15f61ca2e01c79342b8.zip
Fix some GUI bugs in network related panels
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@439 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/GameListPanel.java')
-rw-r--r--src/jrummikub/view/impl/GameListPanel.java27
1 files changed, 9 insertions, 18 deletions
diff --git a/src/jrummikub/view/impl/GameListPanel.java b/src/jrummikub/view/impl/GameListPanel.java
index 2d07f2e..3041d1a 100644
--- a/src/jrummikub/view/impl/GameListPanel.java
+++ b/src/jrummikub/view/impl/GameListPanel.java
@@ -6,7 +6,7 @@ import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.swing.Box;
@@ -41,7 +41,7 @@ class GameListPanel extends JPanel implements IGameListPanel {
private Event openNewGameEvent = new Event();
private Event cancelEvent = new Event();
- private List<GameData> games = new ArrayList<GameData>();
+ private List<GameData> games = Collections.emptyList();
GameListPanel() {
setLayout(new GridBagLayout());
@@ -123,29 +123,20 @@ class GameListPanel extends JPanel implements IGameListPanel {
}
@Override
- public void addGame(GameData game) {
- if (!games.contains(game)) {
- games.add(game);
- }
-
- updateModel();
- }
+ public void setGameList(List<GameData> games) {
+ this.games = games;
- @Override
- public void removeGame(GameData game) {
- if (games.remove(game)) {
- updateModel();
- }
- }
+ Object currentGame = gameList.getSelectedValue();
- private void updateModel() {
DefaultListModel model = new DefaultListModel();
-
for (GameData game : games) {
model.addElement(game);
}
-
gameList.setModel(model);
+
+ if (games.contains(currentGame)) {
+ gameList.setSelectedValue(currentGame, false);
+ }
}
@Override