33 lines
769 B
Java
33 lines
769 B
Java
|
import javax.swing.JPanel;
|
||
|
import java.awt.*;
|
||
|
|
||
|
|
||
|
public class Cell extends JPanel {
|
||
|
private CellType type;
|
||
|
|
||
|
private static final int offset = 2;
|
||
|
private static final int arc = 5;
|
||
|
|
||
|
public Cell() {
|
||
|
super();
|
||
|
setOpaque(false);
|
||
|
type = CellType.EMPTY;
|
||
|
}
|
||
|
|
||
|
public CellType getType() {
|
||
|
return type;
|
||
|
}
|
||
|
|
||
|
public void setType(CellType type) {
|
||
|
this.type = type;
|
||
|
}
|
||
|
|
||
|
protected void paintComponent(Graphics g) {
|
||
|
Graphics ng = g.create();
|
||
|
((Graphics2D)ng).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||
|
|
||
|
ng.setColor(type.getColor());
|
||
|
ng.fillRoundRect(offset, offset, getWidth() - offset * 2, getHeight() - offset * 2, arc, arc);
|
||
|
}
|
||
|
}
|