summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/GameListPanel.java
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-06-11 00:02:42 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-06-11 00:02:42 +0200
commitcc4797fd8b894cc7e02346dc93f891cccb4c0a09 (patch)
treecfa8d3777d8b07ce488573a80ae04ff5aeed1775 /src/jrummikub/view/impl/GameListPanel.java
parent9c553786f2e0e395149a5ef5e27d24d7d944fe3e (diff)
downloadJRummikub-cc4797fd8b894cc7e02346dc93f891cccb4c0a09.tar
JRummikub-cc4797fd8b894cc7e02346dc93f891cccb4c0a09.zip
Netzwerk hat Panel mit laufenden Spielen und einem funktionierenden Abbrechen-Button
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@406 72836036-5685-4462-b002-a69064685172
Diffstat (limited to 'src/jrummikub/view/impl/GameListPanel.java')
-rw-r--r--src/jrummikub/view/impl/GameListPanel.java111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/jrummikub/view/impl/GameListPanel.java b/src/jrummikub/view/impl/GameListPanel.java
new file mode 100644
index 0000000..d509a6e
--- /dev/null
+++ b/src/jrummikub/view/impl/GameListPanel.java
@@ -0,0 +1,111 @@
+package jrummikub.view.impl;
+
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.Box;
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.border.CompoundBorder;
+import javax.swing.border.EmptyBorder;
+import javax.swing.border.LineBorder;
+
+import jrummikub.util.Event;
+import jrummikub.util.Event1;
+import jrummikub.util.IEvent;
+import jrummikub.util.IEvent1;
+import jrummikub.view.IGameListPanel;
+
+class GameListPanel extends JPanel implements IGameListPanel {
+ private JLabel title;
+ private JList gameList;
+ private JButton joinButton;
+ private JButton openNewGameButton;
+ private JButton cancelButton;
+ private Event1<GameData> joinEvent = new Event1<GameData>();
+ private Event openNewGameEvent = new Event();
+ private Event cancelEvent = new Event();
+
+ GameListPanel() {
+ setLayout(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.BOTH;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ c.weightx = 1;
+ c.weighty = 0;
+
+ title = new JLabel();
+ add(title, c);
+
+ gameList = new JList();
+ c.weighty = 1;
+ add(new JScrollPane(gameList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), c);
+
+ joinButton = new JButton("Beitreten");
+ c.weighty = 0;
+ c.gridwidth = 1;
+ add(joinButton, c);
+ joinButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // TODO Auto-generated method stub
+ // joinEvent.emit();
+ }
+ });
+
+ c.weightx = 0;
+ add(Box.createHorizontalStrut(10), c);
+
+ openNewGameButton = new JButton("Neues Spiel");
+ c.weightx = 1;
+ add(openNewGameButton, c);
+ openNewGameButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent arg0) {
+ // TODO Auto-generated method stub
+ openNewGameEvent.emit();
+ }
+ });
+
+ c.weightx = 0;
+ add(Box.createHorizontalStrut(10), c);
+
+ cancelButton = new JButton("Abbrechen");
+ c.weightx = 1;
+ c.weighty = 0;
+ c.gridwidth = GridBagConstraints.REMAINDER;
+ add(cancelButton, c);
+ cancelButton.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ cancelEvent.emit();
+ }
+ });
+
+ setBorder(new CompoundBorder(new LineBorder(Color.BLACK),
+ new EmptyBorder(10, 10, 10, 10)));
+ }
+
+ @Override
+ public IEvent getOpenNewGameEvent() {
+ return openNewGameEvent;
+ }
+
+ @Override
+ public IEvent1<GameData> getJoinEvent() {
+ return joinEvent;
+ }
+
+ @Override
+ public IEvent getCancelEvent() {
+ return cancelEvent;
+ }
+
+}