Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie question event handling

Status
Not open for further replies.

gemann

Technical User
May 21, 2002
9
CA
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

 
can you post the rest of the code (ALL of it). from the code here I can see nothing wrong with it as it is here.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top