File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes ActionListener as a parameter for a constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ActionListener as a parameter for a constructor" Watch "ActionListener as a parameter for a constructor" New topic
Author

ActionListener as a parameter for a constructor

Leonardo Fernandes
Greenhorn

Joined: Sep 24, 2003
Posts: 10
Hello, I have a class (PlayButtonPanel) whose constructor has only one parameter, which is an ActionListener object. That's because I want my PlayButtonPanel objects to be created and used by different objects, although all of them must implement ActionListener. I created two other classes, both implementing ActionListener and calling new PlayButtonPanel(this). One of these classes works, but the other gives me a compile time error saying there is no constructor PlayButtonPanel(ClassName). Does anyone have a clue about what's wrong? Do a class have to do anything besides implementing ActionListener and having the actionPerformed method for it to work?
Thanks
Leonardo
Steve Lovelace
Ranch Hand

Joined: Sep 03, 2003
Posts: 125
Without seeing any code, can only guess that in the case of this one class you forgot to putimplements ActionListener in its class statement.


The Inner that is named is not the true Inner.
Leonardo Fernandes
Greenhorn

Joined: Sep 24, 2003
Posts: 10
This code works

This one doesn't
Leonardo Fernandes
Greenhorn

Joined: Sep 24, 2003
Posts: 10
My constructor is like that:
Leonardo Fernandes
Greenhorn

Joined: Sep 24, 2003
Posts: 10
Found out the problem, I was compiling that stuff with an older PlayButtonPanel.class instead of compiling the new PlayButtonPanel.java. "make clean" solved the problem. Sorry if I made anybody waste time with that.
Steve Lovelace
Ranch Hand

Joined: Sep 03, 2003
Posts: 125
Not a waste. It's useful to be reminded that backlevel code can be the cause of a mysterious bug.
[ September 30, 2003: Message edited by: Steve Lovelace ]
 
jQuery in Action, 2nd edition
 
subject: ActionListener as a parameter for a constructor
 
Similar Threads
Redirecting Output
Decoupling the GUI
Constructor
default constructor??
Inner Class