GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Cannot add actionListener to Button ?!? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Cannot add actionListener to Button ?!?" Watch "Cannot add actionListener to Button ?!?" New topic
Author

Cannot add actionListener to Button ?!?

achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi, I made a few minor modifications to a erstwhile working applet and get the following error message :
...
cannot resolve symbol
symbol : variable search
location : class java.awt.Panel
PanelCliInfo.search.ActionListener(this);
...
The complete applet is big, so here is the gist of it :



humanum errare est.
basha khan
Ranch Hand

Joined: Jan 18, 2002
Posts: 87
this is an innerclass problom ..
change
PanelCliInfo.search.addActionListener(this); // this DOES NOT WORK!
to
demoApplet.this.PanelCliInfo.search.addActionListener(this);
this will work
basha
achana chan
Ranch Hand

Joined: Jul 29, 2002
Posts: 277
Hi. Thanks for that, it compiles fine again.

However, when I try to run it after modifying and recompiling, I get this unusual runtime error on the java console :

When I re-instate the original applet without the inner panel p2, it works fine again and does not throw the NullPointer Exception !
The error message is too cryptic for me to begin debugging it. Nice Chrissy treat from JAVA.
Can you please explain the theory behind the "inner class" to me ? It would be nice to understand wy it compiles.

THX
Merry Christmas .

[ December 25, 2002: Message edited by: achana chan ]
basha khan
Ranch Hand

Joined: Jan 18, 2002
Posts: 87
u made a varible for ClientInfo twice and assigned object to local variable.that's the problm..
u can resolve like this,
change
Panel PanelCliInfo = new ClientInfo();//in init() method
to
PanelCliInfo = new ClientInfo();
that's all
basha
 
GeeCON Prague 2014
 
subject: Cannot add actionListener to Button ?!?