//XXX
//super(false);
this.player = player;
// The player can type their name.
nameLabel = new JLabel("Your name:", JLabel.RIGHT);
nameField = new JTextField(20);
nameField.setText(player.params.getName());
// The player can enter a seed value for their card.
seedLabel = new JLabel("A random number seed:", JLabel.RIGHT);
seedField = new JTextField(new Long(seed).toString(), 20);
// The player can choose the number of cards to play (1-MAX_NUM_CARDS).
cardsLabel = new JLabel(cardsString, JLabel.RIGHT);
String rbString;
char rbChar;
int num;
ButtonGroup group = new ButtonGroup();
cardRB = new JRadioButton[MAX_NUM_CARDS]; //XXX
for (int i = 0; i < MAX_NUM_CARDS; i++) {
num = i + 1;
rbString = new Integer(num).toString();
rbChar = rbString.charAt(0);
cardRB[i] = new JRadioButton(rbString);
cardRB[i].setActionCommand(rbString);
cardRB[i].setMnemonic(rbChar);
cardRB[i].addActionListener(player);
group.add(cardRB[i]);
}
int numCards = player.params.getNumCards();
if (numCards < MAX_NUM_CARDS) {
cardRB[numCards - 1].setSelected(true);
} else {
cardRB[MAX_NUM_CARDS - 1].setSelected(true);
}
//XXXNeed to delete Player.one, etc.
// Choose the host that the GameKeeper is running on.
hostLabel = new JLabel(hostString, JLabel.RIGHT);
hostField = new JTextField(20);
hostField.setText(player.params.getHostname());
/*
* The player clicks this button when
* ready to register.
*/
registerButton = new JButton(Player.register);
registerButton.setMnemonic(Player.registerKey);
registerButton.setActionCommand(Player.register);
registerButton.addActionListener(player);
/*
* The player clicks this button after a game
* is finished to clear the game.
*/
clearButton = new JButton(Player.clear);
clearButton.setMnemonic(Player.clearKey);
clearButton.setActionCommand(Player.clear);
clearButton.addActionListener(player);
clearButton.setEnabled(false);
// Do the layout.
JPanel parameters = new JPanel(false);
GridBagLayout gridbag = new GridBagLayout();
parameters.setLayout(gridbag);
parameters.setBorder(BorderFactory.createTitledBorder(
parametersTitle));
// three rows
Utilities.addParameterRow(parameters, nameLabel, nameField);
Utilities.addParameterRow(parameters, seedLabel, seedField);
Utilities.addParameterRow(parameters, hostLabel, hostField);
// radio button row
Box cardNumBox = Utilities.makeEvenlySpacedBox(cardRB);
Utilities.addParameterRow(parameters, cardsLabel, cardNumBox);
// register and clear buttons
JComponent compList[] = new JComponent[2];
compList[0] = registerButton;
compList[1] = clearButton;
Box buttonBox = Utilities.makeEvenlySpacedBox(compList);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
add(parameters);
add(Box.createRigidArea(new Dimension(Player.BIGPAD,
Player.BIGPAD)));
add(buttonBox);
add(Box.createRigidArea(new Dimension(Player.BIGPAD,
Player.BIGPAD)));