use of games.strategy.ui.IntTextField in project triplea by triplea-game.
the class ClientOptions method initComponents.
private void initComponents() {
nameField = new JTextField(10);
addressField = new JTextField(10);
portField = new IntTextField(0, Integer.MAX_VALUE);
portField.setColumns(7);
}
use of games.strategy.ui.IntTextField in project triplea by triplea-game.
the class NumberProperty method getEditorComponent.
@Override
public JComponent getEditorComponent() {
final IntTextField field = new IntTextField(min, max);
field.setValue(m_value);
field.addChangeListener(aField -> m_value = aField.getValue());
return field;
}
use of games.strategy.ui.IntTextField in project triplea by triplea-game.
the class ServerOptions method initComponents.
private void initComponents() {
nameField = new JTextField(10);
portField = new IntTextField(0, Integer.MAX_VALUE);
portField.setColumns(7);
passwordField = new JPasswordField();
passwordField.setColumns(10);
comment = new JTextField();
comment.setColumns(20);
}
use of games.strategy.ui.IntTextField in project triplea by triplea-game.
the class GameMenu method addRollDice.
private void addRollDice() {
final JMenuItem rollDiceBox = new JMenuItem("Roll Dice");
rollDiceBox.setMnemonic(KeyEvent.VK_R);
rollDiceBox.addActionListener(e -> {
final IntTextField numberOfText = new IntTextField(0, 100);
final IntTextField diceSidesText = new IntTextField(1, 200);
numberOfText.setText(String.valueOf(0));
diceSidesText.setText(String.valueOf(gameData.getDiceSides()));
final JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(new JLabel("Number of Dice to Roll: "), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 20), 0, 0));
panel.add(new JLabel("Sides on the Dice: "), new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 20, 0, 10), 0, 0));
panel.add(numberOfText, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 20), 0, 0));
panel.add(diceSidesText, new GridBagConstraints(2, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 20, 0, 10), 0, 0));
JOptionPane.showOptionDialog(JOptionPane.getFrameForComponent(this), panel, "Roll Dice", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] { "OK" }, "OK");
try {
final int numberOfDice = Integer.parseInt(numberOfText.getText());
if (numberOfDice > 0) {
final int diceSides = Integer.parseInt(diceSidesText.getText());
final int[] dice = game.getRandomSource().getRandom(diceSides, numberOfDice, "Rolling Dice, no effect on game.");
final JPanel panelDice = new JPanel();
final BoxLayout layout = new BoxLayout(panelDice, BoxLayout.Y_AXIS);
panelDice.setLayout(layout);
final JLabel label = new JLabel("Rolls (no effect on game): ");
panelDice.add(label);
final StringBuilder diceString = new StringBuilder();
for (int i = 0; i < dice.length; i++) {
diceString.append(String.valueOf(dice[i] + 1)).append((i == dice.length - 1) ? "" : ", ");
}
final JTextField diceList = new JTextField(diceString.toString());
diceList.setEditable(false);
panelDice.add(diceList);
JOptionPane.showMessageDialog(frame, panelDice, "Dice Rolled", JOptionPane.INFORMATION_MESSAGE);
}
} catch (final Exception ex) {
// ignore malformed input
}
});
add(rollDiceBox);
}
Aggregations