This is my first time writing a applet, and I'm getting an error that it is not initialized. I was pretty sure I did everything the book said to do, so I'm wondering if anyone could take a look at my code and see where I might have done something wrong. The CheckBoxApplet.java file does compile, but the applet does not initialize. CheckBoxApplet.java
Could you please send us the exact error message that is thrown in the "Applet Console" of the browser. As a reminder, you have to put the applet in the same directory as the html (that contains the applet tag) resides. Another cause may be the POLICY file. Sabbir
Yeah, I have the applet file and the html file in the same directory. Here is what the screen said: [error] C:\myjava\assignment2\problem1>javac CheckBoxApplet.java C:\myjava\assignment2\problem1>appletViewer CheckBoxApplet.html java.lang.ClassCastException: CheckBoxApplet at sun.applet.AppletPanel.createApplet(AppletPanel.java:579) at sun.applet.AppletPanel.runLoader(AppletPanel.java:515) at sun.applet.AppletPanel.run(AppletPanel.java:293) at java.lang.Thread.run(Thread.java:484) C:\myjava\assignment2\problem1> [/error] The applet window itself says "Start: applet not initialized." In the Browser it doesn't say anything, it's just a grey box. Also, I don't know what you mean by Policy file. ------------------ Thanks, Dianne
Hi Dianne, In order to create an applet you need to subclass 1 of 2 classes: java.awt.Applet or javax.swing.JApplet Which of these two have you subclassed? Regards, Manfred.
In order to run a class as an applet it must be declared public(as you have done) also it must subclass java.applet.Applet(you could also use the JApplet). regards, /Peter
Originally posted by Dianne Calhoun: [B]This is my first time writing a applet, and I'm getting an error that it is not initialized. I was pretty sure I did everything the book said to do, so I'm wondering if anyone could take a look at my code and see where I might have done something wrong. The CheckBoxApplet.java file does compile, but the applet does not initialize. CheckBoxApplet.java
Okay, I see now. I had to change the CheckBoxApplet extends JFrame to CheckBoxApplet extends JApplet. It works great now. ------------------ Thanks, Dianne
to start, posting to an 11-year-old post, with a number of replies already,
cuts down the number of people that will see your post.
much better to start your own topic (use the same subject if you like),
then post the code you've tried and explain the problem, or the steps to recreate the problem,
and I'm sure you'll get an answer in a reasonably quick time.