This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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:
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
Joined: Aug 14, 2001
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.