Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help with a class in an applet

 
Josh Tambini
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i cant figure out why the current class doesnt work in the applet...


and this is the applet code:


when the class code was implemented int the applet code (in the init class) and the variables delaration also were in the applet code(without the class..) all worked fine..but now with the class it doest..the applet run ,but i get the following exceptions:


anyidea???
10x in advance
 
Barry Higgins
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't try and run your code but a quick glance would suggest that SetUpGUIClass doesn't need to extend Applet.
Is that right,
Barry
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, admittedly I don't have much experience with applets, but I would suggest this is the problem



I don't think both classes can extend applet, indeed your GUI class doesn't need to, you just need one applet class. So, when you try to use an applet specific method (getParameter()) in the GUI class, because that isn't really an applet that's running it doesn't work.

I would suggest making SetUpGUIClass a plain class and passing this parameter in via the constructor...

 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, I just realised also that a lot of your GUI type code is also based on applet type methods. Instead of extending applet for the GUI stuff you really need to extend some component, like JPanel, and then add it to the layout in the proper applet class.

However, this might just end up confusing you. Why not just keep the GUI code in the applet if it's not going to be too complex? If this is to be a complex applet then you will have to invest some more time covering the basics of applets and GUI's.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic