Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

number of buttons double when I reload an applet, why?  RSS feed

 
Gregory Banks
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have an applet that declares a bunch of JButtons in private static class variables. I initialize these buttons in the init method which I thought was only supposed to be called once when the browser first creates the applet. However, when I go to another page and come back all of the buttons have been doubled. If I go and return again they have been tripled, and so on. The same thing happens if I reload the applet. Only the original buttons maintain their listeners for events. The others are just empty. How do I avoid this without initializing them outside of the init method? Any help would be greatly appreciated. Thanks.
Cheers,
Greg
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!