aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JButton on multiple instances of applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton on multiple instances of applet" Watch "JButton on multiple instances of applet" New topic
Author

JButton on multiple instances of applet

Alfred Harre
Ranch Hand

Joined: Apr 29, 2004
Posts: 73
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

Joined: Jan 14, 2004
Posts: 1535
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:
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: JButton on multiple instances of applet