Added wood texture to board
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@11 72836036-5685-4462-b002-a69064685172
This commit is contained in:
parent
082b699c32
commit
2a4e4f0a83
4 changed files with 59 additions and 1 deletions
|
@ -3,5 +3,6 @@
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="test"/>
|
<classpathentry kind="src" path="test"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,12 +1,27 @@
|
||||||
package jrummikub.view;
|
package jrummikub.view;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class Board extends JPanel implements IBoard {
|
public class Board extends JPanel implements IBoard {
|
||||||
|
private final static ImageIcon background = new ImageIcon(Board.class.getResource("resource/wood.png"));
|
||||||
|
|
||||||
Board() {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
42
src/jrummikub/view/CustomBorder.java
Normal file
42
src/jrummikub/view/CustomBorder.java
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
BIN
src/jrummikub/view/resource/wood.png
Normal file
BIN
src/jrummikub/view/resource/wood.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
Reference in a new issue