![]() |
Shouldnt this work?
ok, i'm confused why this doesnt work
:
it compiles, but when i run it in blueJ it give me this "applet not initialized" |
It's been a while sicne I extended a class, but I seem to remember you tended to need certain methods or you'd get an error like that.
Are you sure you have all the required methods for it to work? (I've never sued applets so I wouldn't know) |
Ah, I just realised exactly what's wrong!
IIRC, the fist thing you have to do when extending a class is call the super class in the contruction method. Try this: :
|
@Tsar_of_Cows: When a GuiExample object is created, the super class, JApplet's constructor will automatically be called right before the GuiExample's constructor. It's all OOP.
|
Now it says "do not use GuiExample.add() use GuiExample.getContentPane().add() instead." then it gives me the original error
|
Your code (crawforddavid2006) works fine for me (although the window layout leaves much to be desired). There may be some special way to initialize an applet in BlueJ before it can run; however, I suggest you find a real IDE/compiler instead.
|
Quote:
|
No; it's specific to the Java language.
|
It's not even really specific to Java. When you create an object, if you do not explicity call the super constructor, then the superclass' default constructor will be called... sort of. That way, all of the super class' memory space gets initialized at the very least. It wouldn't really make sense if it didn't. If you don't get it, don't worry. I didn't really get it until I wrote an entire program, which you are planning on doing now anyway, right?
Cheers. The applet works for me. Here is my html code (pretty much taken from the example) :
<HTML>I used JDK 6.1 on Vista Business to test this. |
| All times are GMT -5. The time now is 2:40 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC