summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/TablePanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl/TablePanel.java')
-rw-r--r--src/jrummikub/view/impl/TablePanel.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/jrummikub/view/impl/TablePanel.java b/src/jrummikub/view/impl/TablePanel.java
index f34765e..7eb798d 100644
--- a/src/jrummikub/view/impl/TablePanel.java
+++ b/src/jrummikub/view/impl/TablePanel.java
@@ -4,6 +4,7 @@ import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
+import java.awt.Point;
import java.awt.Shape;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
@@ -17,11 +18,13 @@ import java.util.List;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
+import javax.swing.SwingUtilities;
import jrummikub.model.Position;
import jrummikub.model.Stone;
import jrummikub.model.StoneSet;
import jrummikub.util.Event1;
+import jrummikub.util.IListener1;
import jrummikub.util.Pair;
import jrummikub.view.IStoneCollectionPanel;
import jrummikub.view.ITablePanel;
@@ -114,12 +117,7 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
repaint();
}
- /**
- * Creates a new Table instance
- */
- TablePanel() {
- setLayout(null);
-
+ private void createLabels() {
leftPlayerLabel = new JLabel();
leftPlayerLabel.setForeground(Color.WHITE);
leftPlayerLabel.setHorizontalAlignment(JLabel.LEFT);
@@ -139,8 +137,24 @@ class TablePanel extends AbstractStonePanel implements ITablePanel {
rightPlayerLabel.setHorizontalAlignment(JLabel.RIGHT);
rightPlayerLabel.setHorizontalTextPosition(JLabel.RIGHT);
add(rightPlayerLabel);
+ }
+
+ /**
+ * Creates a new Table instance
+ */
+ TablePanel() {
+ setLayout(null);
+
+ createLabels();
stoneCollection = new StoneCollectionPanel();
+ stoneCollection.getOtherClickEvent().add(new IListener1<Point>() {
+
+ @Override
+ public void handle(Point p) {
+ Point p2 = SwingUtilities.convertPoint(stoneCollection, p, TablePanel.this);
+ clickAt(p2, 1, false, false);
+ }});
add(stoneCollection);
addComponentListener(new ComponentAdapter() {