From c84bebceb7690410c33ae15f61ca2e01c79342b8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 14 Jun 2011 17:57:19 +0200 Subject: 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 --- src/jrummikub/view/impl/GameListPanel.java | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'src/jrummikub/view/impl/GameListPanel.java') 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 games = new ArrayList(); + private List 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 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 -- cgit v1.2.3