Hi, I have two inner classes
class StartGameButtonListener implements ActionListener and
class HitButtonListener implements ActionListener
When I click on the startGameButton it works, it removes 2 cards from the deck and displays them in the textfield.
But when I click on the hitButton nothing happens.
Here is a small section of the code:
class StartGameButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
CardDeck deck = new CardDeck();
deck.shuffle();
Hand myHand = deck.dealHand(2);
Hand yourHand = deck.dealHand(2);
input1TextField.setText(" " + (myHand));
}
}
class HitButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
CardDeck deck = new CardDeck();
final JTextField input1TextField = new JTextField(10);
Hand myHand = deck.dealHand(1);
input1TextField.setText(" " + (myHand));
}
}
// Create a listener object to respond to the "Hit, Stay,
// Start Game and End Game button and register it,
// all in one step.
endGameButton.addActionListener(new EndGameButtonListener());
startGameButton.addActionListener(new StartGameButtonListener());
hitButton.addActionListener(new HitButtonListener());
aFrame.setVisible(true);
Thanks gemann
class StartGameButtonListener implements ActionListener and
class HitButtonListener implements ActionListener
When I click on the startGameButton it works, it removes 2 cards from the deck and displays them in the textfield.
But when I click on the hitButton nothing happens.
Here is a small section of the code:
class StartGameButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
CardDeck deck = new CardDeck();
deck.shuffle();
Hand myHand = deck.dealHand(2);
Hand yourHand = deck.dealHand(2);
input1TextField.setText(" " + (myHand));
}
}
class HitButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
CardDeck deck = new CardDeck();
final JTextField input1TextField = new JTextField(10);
Hand myHand = deck.dealHand(1);
input1TextField.setText(" " + (myHand));
}
}
// Create a listener object to respond to the "Hit, Stay,
// Start Game and End Game button and register it,
// all in one step.
endGameButton.addActionListener(new EndGameButtonListener());
startGameButton.addActionListener(new StartGameButtonListener());
hitButton.addActionListener(new HitButtonListener());
aFrame.setVisible(true);
Thanks gemann