wood burning stoves
The moose likes Beginning Java and the fly likes help with a class in an applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help with a class in an applet" Watch "help with a class in an applet" New topic

help with a class in an applet

Josh Tambini

Joined: Nov 30, 2004
Posts: 24
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:

10x in advance
Barry Higgins
Ranch Hand

Joined: Jun 05, 2003
Posts: 89
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,
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
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...

SCJP 1.4, www.gsi3d.org.uk
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: help with a class in an applet
It's not a secret anymore!