• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JButton on multiple instances of applet

 
Alfred Harre
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I have an applet that uses JFrame and JFrame has JButton on it.
when I start multiple instances of this Frame, JButtons work only on the last frame/window and become inactive on any precding window.
Any ideas and help is greatly appreciated.
Regards
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you're trying to reuse an instance variable in class scope, like this:

Here each listener is registered on only one (the last) button.
Try it with button as a local variable, ie, make a separate JButton for each call from launch. Then each button has its own listener. Like this:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic