Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot add actionListener to Button ?!?

 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :

 
basha khan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic