Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
using buttons and checkboxes Posted by ricka138 on 29 Mar 2006 at 6:25 PM
I need to use a single button and some checkboxes in my program. I have implements ItemListener in the header to use the checkboxes but how do I get the button to work. It needs to clear the text field. Do I need to implement the ActionListener some how?

Thanks!

Report
Re: using buttons and checkboxes Posted by zibadian on 29 Mar 2006 at 7:06 PM
: I need to use a single button and some checkboxes in my program. I have implements ItemListener in the header to use the checkboxes but how do I get the button to work. It needs to clear the text field. Do I need to implement the ActionListener some how?
:
: Thanks!
:
:
Yes, you need to implement the ActionListener. This requires the actionPerformed(ActionEvent e) method, in which you can clear the text field (= set the text of the text field to an empty string). The button has a method called addActionListener() to link the ActionListener to it.
Report
Re: using buttons and checkboxes Posted by ricka138 on 29 Mar 2006 at 7:27 PM
: Yes, you need to implement the ActionListener. This requires the actionPerformed(ActionEvent e) method, in which you can clear the text field (= set the text of the text field to an empty string). The button has a method called addActionListener() to link the ActionListener to it.
:

Ok, how do i do that when my header is as follows:

public class PetAdviceApplet extends Applet implements ItemListener

I used the ItemListener so I could use the checkboxes as well. How do I use both checkboxes and a button. When I try to put the addActionListener() in with my button in the init() method I get an error that it cannot be applied?

Any ideas?

Thanks again!!!!
Report
Re: using buttons and checkboxes Posted by zibadian on 29 Mar 2006 at 7:29 PM
: : Yes, you need to implement the ActionListener. This requires the actionPerformed(ActionEvent e) method, in which you can clear the text field (= set the text of the text field to an empty string). The button has a method called addActionListener() to link the ActionListener to it.
: :
:
: Ok, how do i do that when my header is as follows:
:
: public class PetAdviceApplet extends Applet implements ItemListener
:
: I used the ItemListener so I could use the checkboxes as well. How do I use both checkboxes and a button. When I try to put the addActionListener() in with my button in the init() method I get an error that it cannot be applied?
:
: Any ideas?
:
: Thanks again!!!!
:
You can add more than 1 interface to a class:
public class PetAdviceApplet extends Applet implements ItemListener, ActionListener


Report
Re: using buttons and checkboxes Posted by ricka138 on 29 Mar 2006 at 7:32 PM
: : : Yes, you need to implement the ActionListener. This requires the actionPerformed(ActionEvent e) method, in which you can clear the text field (= set the text of the text field to an empty string). The button has a method called addActionListener() to link the ActionListener to it.
: : :
: :
: : Ok, how do i do that when my header is as follows:
: :
: : public class PetAdviceApplet extends Applet implements ItemListener
: :
: : I used the ItemListener so I could use the checkboxes as well. How do I use both checkboxes and a button. When I try to put the addActionListener() in with my button in the init() method I get an error that it cannot be applied?
: :
: : Any ideas?
: :
: : Thanks again!!!!
: :
: You can add more than 1 interface to a class:
:
: public class PetAdviceApplet extends Applet implements ItemListener, ActionListener
: 

:
:

Thankyou so much! That's the only thing I've been struggling with. Thanks again! God Bless!!!




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.