File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Help with Jbuttons JText  Lotto Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Help with Jbuttons JText  Lotto" Watch "Help with Jbuttons JText  Lotto" New topic
Author

Help with Jbuttons JText Lotto

Alan Green
Greenhorn

Joined: Sep 07, 2003
Posts: 17
I am doing homework writting a lotto program my number text fields must be an array of text fields, and there must be an array of integers to hold the user's numbers as numbers. I am trying to set my JButtons for play and reset using Action Performed. When I compile I continue to get the error
cannot resolve symbol method addActionListener. Can someone help me with this problem.
Srivani Nallan
Greenhorn

Joined: Apr 11, 2003
Posts: 16
You need to check for the action command and then have your play method or clear the fields.
For Example:
public void actionPerformed (ActionEvent event){
if(event.getActionCommand().equals("Play")){
//do something
}
if(event.getActionCommand().equals("Reset")){
//clear the fields
}
}
Eddie Vanda
Ranch Hand

Joined: Mar 18, 2003
Posts: 281
Hi Isa

You have an array of textfields, in numberField array. You can't add an ActionListener to an array, they would have to be added to each textfield in turn, assuming you really want to have action listeners on your textfields. So change scope of for statement you could have:

What you had should not have compiled, so maybe you've already fixed it?


The nice thing about Standards is that there are so many to choose from!
Alan Green
Greenhorn

Joined: Sep 07, 2003
Posts: 17
should i be able to see the play and reset buttons on the applet before i right the perform method... because i don't see it when executing..
Alan Green
Greenhorn

Joined: Sep 07, 2003
Posts: 17
I am still getting the Assmt4 should be declared abstract it does not define action Performed..

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Moving to the Swing forum.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Isa,
We don't have too many rules around here, but we do have a Naming Policy. Please adjust your display name accordingly.
You can change your display name here.
Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with Jbuttons JText Lotto