summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/view/Board.java17
-rw-r--r--src/jrummikub/view/CustomBorder.java42
-rw-r--r--src/jrummikub/view/resource/wood.pngbin0 -> 35308 bytes
3 files changed, 58 insertions, 1 deletions
diff --git a/src/jrummikub/view/Board.java b/src/jrummikub/view/Board.java
index 70c0988..b73b00a 100644
--- a/src/jrummikub/view/Board.java
+++ b/src/jrummikub/view/Board.java
@@ -1,12 +1,27 @@
package jrummikub.view;
import java.awt.Color;
+import java.awt.Graphics;
+import javax.swing.ImageIcon;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class Board extends JPanel implements IBoard {
+ private final static ImageIcon background = new ImageIcon(Board.class.getResource("resource/wood.png"));
+
Board() {
- setBackground(Color.DARK_GRAY);
+ super(true);
+
+ setBorder(new CustomBorder(Color.DARK_GRAY, 0, 1, 0, 1));
+ }
+
+ @Override
+ protected void paintComponent(Graphics g) {
+ for(int x = 0; x < getWidth(); x += background.getIconWidth()) {
+ background.paintIcon(this, g, x, 0);
+ }
+
+ // TODO Rest of painting code
}
}
diff --git a/src/jrummikub/view/CustomBorder.java b/src/jrummikub/view/CustomBorder.java
new file mode 100644
index 0000000..f249cb1
--- /dev/null
+++ b/src/jrummikub/view/CustomBorder.java
@@ -0,0 +1,42 @@
+package jrummikub.view;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.Insets;
+
+import javax.swing.border.Border;
+
+class CustomBorder implements Border {
+ private Color color;
+ private int top, left, bottom, right;
+
+ public CustomBorder(Color color, int top, int left, int bottom, int right) {
+ this.color = color;
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ }
+
+ @Override
+ public Insets getBorderInsets(Component c) {
+ return new Insets(top, left, bottom, right);
+ }
+
+ @Override
+ public boolean isBorderOpaque() {
+ return true;
+ }
+
+ @Override
+ public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
+ g.setColor(color);
+
+ g.fillRect(x, y, width, top);
+ g.fillRect(x, y+height-bottom, width, bottom);
+ g.fillRect(x, y, left, height);
+ g.fillRect(x+width-right, y, right, height);
+ }
+
+}
diff --git a/src/jrummikub/view/resource/wood.png b/src/jrummikub/view/resource/wood.png
new file mode 100644
index 0000000..424ec6d
--- /dev/null
+++ b/src/jrummikub/view/resource/wood.png
Binary files differ