import java.awt.*; public class pnlBingoSquare extends Panel{ private String strCaption = ""; private String strID = ""; private int intStatus = 0; public pnlBingoSquare(String caption) { strCaption = caption; setBackground(Color.white); } public void paint(Graphics g) { FontMetrics fm = g.getFontMetrics(); Dimension d = size(); int intH = fm.getHeight(); int intX = (d.height - intH) / 2 + 11; int intW = fm.stringWidth(strCaption); int intY = (d.width - intW) /2; switch (intStatus) { case 1: g.setColor(Color.yellow); break; case 2: g.setColor(Color.green); break; default: g.setColor(Color.white); } g.fillOval(1, 1, d.width, d.height); g.setColor(Color.black); g.drawString(strCaption, intY, intX); g.drawRect(0, 0, d.width-1, d.height-1); } public void setCaption(String caption) { strCaption = caption; repaint(); } public String getCaption() { return strCaption; } public void setStatus(int status) { intStatus = status; repaint(); } public int getStatus() { return intStatus; } public void setID(String id) { strID = id; } public String getID() { return strID; } }