/** * constructor - creates and displays a new dialog box to obtain each player's bet before the game * process actually begins * * @param parent - reference to the parent frame of this box * @param modal - whether or not this box should be made modal (whether it MUST be dealt with * before anything else) * @param turnIndex - number to which player is currently betting; used to set the button colors */ public BetInputDialog(BlackJackFrame parent, boolean modal, int turnIndex) { super(parent, modal); this.parent = parent; inputPanel = new JPanel(); buttonsPanel = new JPanel(); betField = new JTextField(10); enterButton = new JButton("Bet!"); enterButton.setToolTipText("Enter your bet for this hand."); skipHandButton = new JButton("Skip Hand"); skipHandButton.setToolTipText("Choose to sit out this hand."); enterButton.addActionListener(this); skipHandButton.addActionListener(this); inputPanel.add(betField); buttonsPanel.add(enterButton); buttonsPanel.add(skipHandButton); setButtonColors(turnIndex); setLayout(new GridLayout(2, 1)); add(inputPanel); add(buttonsPanel); getRootPane().setDefaultButton(enterButton); setTitle( "Starting Hand " + parent.getCurrentHandNumber() + ", " + parent.getCurrentPlayer().getName() + "\'s turn"); setSize(300, 100); setLocationRelativeTo(null); setResizable(false); setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); setVisible(true); }