super("Bingo Card");
this.card = card;
this.player = player;
BingoBall[][] boardValues = card.boardValues;
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
PaperPane paper = new PaperPane(null);
getContentPane().add("Center", paper);
JPanel numberPanel = new JPanel(false);
numberPanel.setLayout(new GridLayout(cellsPerSide+1,
cellsPerSide));
Heading heading;
char c;
for (int col = 0; col < cellsPerSide; col++) {
heading = new Heading(card.columnTitles[col]);
numberPanel.add(heading);
}
NumberButton button;
int number;
for (int col = 0; col < cellsPerSide; col++) {
for (int row = 0; row < cellsPerSide; row++) {
number = boardValues[col][row].getNumber();
if (number == BingoBall.FREE_SPACE) {
//XXX should use an icon for free space.
button = new NumberButton("Free");
} else {
button = new NumberButton(Integer.toString(number));
}
numberPanel.add(button);
}
}
//XXX: Could make the winner button use an icon.
JButton winner = new JButton("Bingo! I won! Bingo!");
winner.addActionListener(this);
//Now that we've created the components, do the layout.
paper.setLayout(new BoxLayout(paper, BoxLayout.Y_AXIS));
paper.add(numberPanel);
//extra vertical space
paper.add(Box.createVerticalStrut(10));
winner.setAlignmentX(0.5f);
paper.add(winner);
//extra vertical space
paper.add(Box.createVerticalStrut(10));