APL/DEV 3.2/TP05/Serpent/Cell.java

33 lines
769 B
Java
Raw Normal View History

2022-11-17 16:20:15 +01:00
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);
}
}