2011-04-27 20:25:37 +02:00
|
|
|
package jrummikub.view;
|
|
|
|
|
|
|
|
import java.awt.BorderLayout;
|
2011-04-28 15:32:32 +02:00
|
|
|
import java.awt.Color;
|
2011-04-27 22:21:42 +02:00
|
|
|
import java.awt.Graphics;
|
2011-04-27 20:25:37 +02:00
|
|
|
|
2011-04-27 22:21:42 +02:00
|
|
|
import javax.swing.ImageIcon;
|
2011-04-27 20:25:37 +02:00
|
|
|
import javax.swing.JLabel;
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
public class Table extends JPanel implements ITable {
|
2011-04-27 22:21:42 +02:00
|
|
|
private final static ImageIcon background = new ImageIcon(Board.class.getResource("resource/felt.png"));
|
|
|
|
|
2011-04-27 20:25:37 +02:00
|
|
|
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() {
|
2011-04-27 22:21:42 +02:00
|
|
|
super(true); // set double buffered
|
2011-04-27 20:25:37 +02:00
|
|
|
setLayout(new BorderLayout());
|
|
|
|
|
|
|
|
leftPlayerLabel = new JLabel();
|
2011-04-28 15:32:32 +02:00
|
|
|
leftPlayerLabel.setForeground(Color.WHITE);
|
2011-04-27 20:25:37 +02:00
|
|
|
add(leftPlayerLabel, BorderLayout.WEST);
|
|
|
|
|
|
|
|
topPlayerLabel = new JLabel();
|
|
|
|
topPlayerLabel.setHorizontalAlignment(JLabel.CENTER);
|
|
|
|
topPlayerLabel.setHorizontalTextPosition(JLabel.CENTER);
|
2011-04-28 15:32:32 +02:00
|
|
|
topPlayerLabel.setForeground(Color.WHITE);
|
2011-04-27 20:25:37 +02:00
|
|
|
add(topPlayerLabel, BorderLayout.NORTH);
|
|
|
|
|
|
|
|
rightPlayerLabel = new JLabel();
|
2011-04-28 15:32:32 +02:00
|
|
|
rightPlayerLabel.setForeground(Color.WHITE);
|
2011-04-27 20:25:37 +02:00
|
|
|
add(rightPlayerLabel, BorderLayout.EAST);
|
|
|
|
|
|
|
|
innerPanel = new JPanel();
|
|
|
|
innerPanel.setOpaque(false);
|
|
|
|
add(innerPanel, BorderLayout.CENTER);
|
|
|
|
}
|
2011-04-27 22:21:42 +02:00
|
|
|
|
|
|
|
@Override
|
2011-04-28 15:32:32 +02:00
|
|
|
protected void paintComponent(Graphics g) {
|
2011-04-27 22:21:42 +02:00
|
|
|
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
|
|
|
|
}
|
2011-04-27 20:25:37 +02:00
|
|
|
}
|