Paint table background

git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@4 72836036-5685-4462-b002-a69064685172
This commit is contained in:
Matthias Schiffer 2011-04-27 22:21:42 +02:00
parent a526d2efbf
commit 59e4d3664f
3 changed files with 18 additions and 2 deletions

View file

@ -15,7 +15,7 @@ import javax.swing.border.LineBorder;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class PlayerPanel extends JPanel implements IPlayerPanel { public class PlayerPanel extends JPanel implements IPlayerPanel {
private final static DecimalFormat intFormat = new DecimalFormat("00"); private final static DecimalFormat secondFormat = new DecimalFormat("00");
private Board board; private Board board;
@ -40,7 +40,7 @@ public class PlayerPanel extends JPanel implements IPlayerPanel {
public public
void setTimeLeft(int time) { void setTimeLeft(int time) {
timeBar.setValue(time); timeBar.setValue(time);
timeBar.setString(Integer.toString(time/60) + ":" + intFormat.format(time%60)); timeBar.setString(Integer.toString(time/60) + ":" + secondFormat.format(time%60));
} }

View file

@ -1,12 +1,16 @@
package jrummikub.view; package jrummikub.view;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Graphics;
import javax.swing.ImageIcon;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class Table extends JPanel implements ITable { public class Table extends JPanel implements ITable {
private final static ImageIcon background = new ImageIcon(Board.class.getResource("resource/felt.png"));
private JLabel leftPlayerLabel, topPlayerLabel, rightPlayerLabel; private JLabel leftPlayerLabel, topPlayerLabel, rightPlayerLabel;
private JPanel innerPanel; private JPanel innerPanel;
@ -27,6 +31,7 @@ public class Table extends JPanel implements ITable {
} }
Table() { Table() {
super(true); // set double buffered
setLayout(new BorderLayout()); setLayout(new BorderLayout());
leftPlayerLabel = new JLabel(); leftPlayerLabel = new JLabel();
@ -44,4 +49,15 @@ public class Table extends JPanel implements ITable {
innerPanel.setOpaque(false); innerPanel.setOpaque(false);
add(innerPanel, BorderLayout.CENTER); add(innerPanel, BorderLayout.CENTER);
} }
@Override
public void paint(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
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 KiB