![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
Shouldnt this work?
ok, i'm confused why this doesnt work
java Syntax (Toggle Plain Text)
it compiles, but when i run it in blueJ it give me this "applet not initialized"
__________________
|
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jun 2007
Posts: 15
Rep Power: 0
![]() |
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) |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jun 2007
Posts: 15
Rep Power: 0
![]() |
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: java Syntax (Toggle Plain Text)
|
|
|
|
|
|
#4 |
|
Sexy Programmer
|
@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.
__________________
I would love to change the world, but they won't give me the source code! |
|
|
|
|
|
#5 |
|
Expert Programmer
|
Now it says "do not use GuiExample.add() use GuiExample.getContentPane().add() instead." then it gives me the original error
__________________
|
|
|
|
|
|
#6 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: Jun 2007
Posts: 15
Rep Power: 0
![]() |
|
|
|
|
|
|
#8 |
|
Expert Programmer
|
No; it's specific to the Java language.
Last edited by titaniumdecoy; Jun 22nd, 2007 at 7:09 PM. |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3
![]() |
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> <HEAD> <TITLE> Query Output </TITLE> </HEAD> <BODY> Output from query select NAME, PRICE from COFFEES <APPLET CODE="GuiExample.class" WIDTH=250 HEIGHT=200> </APPLET> </BODY> <script language="JavaScript" src="/js/omi/jsc/s_code_remote.js"></script></HTML> I used JDK 6.1 on Vista Business to test this. Last edited by Harakim; Jun 23rd, 2007 at 4:09 AM. Reason: I felt like it. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Thinking about moving to USA to work in software - advice please! | funkey_monkey | Coder's Corner Lounge | 3 | Jan 23rd, 2007 7:56 AM |
| tables dont work in firefox; they work in IE | angry_asian | HTML / XHTML / CSS | 3 | Aug 5th, 2006 6:00 PM |
| Help:::::::: Why Wont This Work?????? | paulchwd | ASP | 1 | Jul 10th, 2005 1:34 PM |
| Can't get loop to work | rockybalboa | Java | 3 | Mar 20th, 2005 6:19 PM |
| 40 Things you'd like to say out loud at work | big_k105 | Coder's Corner Lounge | 11 | Jan 25th, 2005 2:13 AM |