• Post Reply Bookmark Topic Watch Topic
  • New Topic

Implementing multiple listeners (ActionListener and ChangeListener)

 
David Pountney
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I want to implement both an actionListener and a changeListener, how would I go about doing this? As the following doesn't seem to work;

 
Darryl Burke
Bartender
Posts: 5155
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It Doesnt Work Is Useless. To get better help sooner, post a SSCCE (Short, Self Contained, Compilable and Executable) example that demonstrates the problem.
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you call addActionListener and addChangeListener anywhere in your code to attach the class as ActionListener / ChangeListener to some component?
 
David Pountney
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry,


I want to implement both an actionListener and a changeListener in the same class, how would I go about doing this? Is it even possible?




That just says the error message "Can't find symbol"

And this...



Justs says error, "Expecting "{" "

The reason I want two different listeners is because I have a JSpinner conponent in my class and it doesn't use nromal actionListeners by the looks of things.

Any help?
 
Stephan van Hulst
Bartender
Posts: 6583
84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you import java.awt.event.ActionListener and javax.swing.event.ChangeListener?
 
David Pountney
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply

I didn't, I did now though, I still get the same problem;



The error I get is that it can not find the symbol "ChangeListener"

Any ideas?

Thanks
 
Rob Camick
Ranch Hand
Posts: 2700
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.swing.event.ChangeListener.*;


Thats not how you do an import.

You either fully qualify the class name:



or use a wildcard for all classes in the package:

 
David Pountney
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I managed to sort this issue out, I discovered netbeans has a drag and drop design mode. So I just designed it on there and it seems to have have done it for me.

Thanks for the help everyone
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!