summaryrefslogtreecommitdiffstats
path: root/src/jrummikub/view/impl/Table.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jrummikub/view/impl/Table.java')
-rw-r--r--src/jrummikub/view/impl/Table.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/jrummikub/view/impl/Table.java b/src/jrummikub/view/impl/Table.java
new file mode 100644
index 0000000..c3c6a71
--- /dev/null
+++ b/src/jrummikub/view/impl/Table.java
@@ -0,0 +1,69 @@
+package jrummikub.view.impl;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Graphics;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import jrummikub.view.ITable;
+
+@SuppressWarnings("serial")
+public class Table extends JPanel implements ITable {
+ private final static ImageIcon background = new ImageIcon(Board.class.getResource("/jrummikub/resource/felt.png"));
+
+ private JLabel leftPlayerLabel, topPlayerLabel, rightPlayerLabel;
+ private JPanel innerPanel;
+
+
+ @Override
+ public void setLeftPlayerName(String playerName) {
+ leftPlayerLabel.setText(playerName);
+ }
+
+ @Override
+ public void setTopPlayerName(String playerName) {
+ topPlayerLabel.setText(playerName);
+ }
+
+ @Override
+ public void setRightPlayerName(String playerName) {
+ rightPlayerLabel.setText(playerName);
+ }
+
+ Table() {
+ super(true); // set double buffered
+ setLayout(new BorderLayout());
+
+ leftPlayerLabel = new JLabel();
+ leftPlayerLabel.setForeground(Color.WHITE);
+ add(leftPlayerLabel, BorderLayout.WEST);
+
+ topPlayerLabel = new JLabel();
+ topPlayerLabel.setHorizontalAlignment(JLabel.CENTER);
+ topPlayerLabel.setHorizontalTextPosition(JLabel.CENTER);
+ topPlayerLabel.setForeground(Color.WHITE);
+ add(topPlayerLabel, BorderLayout.NORTH);
+
+ rightPlayerLabel = new JLabel();
+ rightPlayerLabel.setForeground(Color.WHITE);
+ add(rightPlayerLabel, BorderLayout.EAST);
+
+ innerPanel = new JPanel();
+ innerPanel.setOpaque(false);
+ add(innerPanel, BorderLayout.CENTER);
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ for(int x = 0; x < getWidth(); x += background.getIconWidth()) {
+ for(int y = 0; y < getHeight(); y += background.getIconHeight()) {
+ background.paintIcon(this, g, x, y);
+ }
+ }
+
+ // TODO Rest of painting code
+ }
+}