Need help with applet plz

I am attempting to make a lesser version of an application I made and put it on a site, as an applet.

the html code is:

<applet codebase="../classes" archive="draconis.jar" code="draconis.MainApplet.class"

alt="(Java not enabled)">

<font color="#FF0000">Sorry! Your browser hates Java!</font>

</applet>

This runs fine, I know it runs fine because I see a gray box (the applet's background is gray, the sites background is white).

I have never done applets before, so I found an applet in action and decompiled the class files to see what I would need to do to get it up.

It didnt work..

publicclass MainAppletextends Applet

{

private GUI gui;

public MainApplet()

{

}

public String getAppletInfo()

{

return"Draconis Applet 2006.";

}

publicvoid init()

{

setBackground(Color.lightGray);

setLayout(new BorderLayout());

gui =new GUI();

add("Center", gui);

}

}

/****************************************************/

publicclass GUIextends Panel

{

/*

PIV's

*/

publicvoid GUI()

{

initComponents();

initPanels();

initEventListeners();

setLayout(new BorderLayout());

add("Center", mainPanel);

}

privatevoid initComponents()

{

/*

init'd

*/

}

privatevoid initPanels()

{

/*

init'd and added to mainPanel

*/

}

privatevoid initEventListeners()

{

execButton.addActionListener(new ActionListener(){

publicvoid actionPerformed(ActionEvent e){

execButton.setEnabled(false);

new ProgBarThread("ProgBar").start();

new ExecThread("Exec").start();

}

});

}

privateclass ExecThreadextends Thread{

public ExecThread(String str){

super(str);

}

publicvoid run(){

/* does stuff */

}

privateclass ProgBarThreadextends Thread{

public ProgBarThread(String str){

super(str);

}

publicvoid run(){

/* turns progress bar on */

}

}

}

There is over 300 lines of code, so I edited out what I know works from my experience(its basically just text fields and buttons getting init'd and put on seperate panels and then the panels placed on the mainPanel which is added to class which is added to the Applet)

It doesnt want to display anything except the background color from the MainApplet class..

I've spent most of the day figuring out applets and trying to get it to show up on the site (I kept getting magc number issues), now im looking for a quick fix for this problem =)

Any ideas would be greatly appreciated!

[5552 byte] By [DarkNomada] at [2007-10-2 10:17:07]
# 1
I just read in another post about how it shows a gray box when the applet isnt loaded, so I changed the applets background to blue and it stayed gray.If that helps narrow down the issue..
DarkNomada at 2007-7-13 1:43:00 > top of Java-index,Java Essentials,New To Java...
# 2
Please excuse triple post but..I got it to show the blue background, but nothing else happens. Same thing when I use appletviewer and Internet Explorer (My current browser is Mozilla FIrefox)
DarkNomada at 2007-7-13 1:43:00 > top of Java-index,Java Essentials,New To Java...
# 3

<quote>This runs fine, I know it runs fine because I see a gray box (the applet's background is gray, the sites background is white).</quote>

Have you tried changing the background to (say) red. I bet the screen does not change!

<quote> have never done applets before,</quote>

Start with something VERY VERY simple then. Not 300 lines of code.

Also, in

add("Center", mainPanel);

whare is 'mainPanel' initialized?

P.S You should use

add(mainPanel, Borderkayout.CENTER);

when you have sorted out the initialization of 'mainPanel'.

sabre150a at 2007-7-13 1:43:00 > top of Java-index,Java Essentials,New To Java...
# 4

Yes, I changed the background to blue and its blue now. It is also no longer square, it is rectangular (I gave it width/height in the html code).

And I am new to applets, not java programming. I edited out the stuff I know is right to save space.. You want to see the initialization of mainPanel? here you go:

private void initPanels()

{

mainPanel = new JPanel();

GridBagLayout gridbag = new GridBagLayout();

GridBagConstraints c = new GridBagConstraints();

mainPanel.setLayout(gridbag);

c.fill = GridBagConstraints.HORIZONTAL;

/* other panels not displayed, to save room */

c.gridwidth = 2;

c.gridx = 0;

c.gridy = 0;

mainPanel.add(filePanel, c);

c.gridwidth = 2;

c.gridx = 0;

c.gridy = 1;

mainPanel.add(setupPanel, c);

c.gridwidth = 1;

c.gridx = 0;

c.gridy = 2;

mainPanel.add(actionPanel, c);

c.gridwidth = 1;

c.gridx = 1;

c.gridy = 2;

mainPanel.add(progPanel, c);

c.gridwidth = 2;

c.gridx = 0;

c.gridy = 3;

mainPanel.add(outPanel, c);

}

That method is called before mainPanel is added.

I changed the add method for mainPanel.

I started out with 300+ lines of code because I didnt think applets would be this complicated.

Also, when I load the applet in appletviewer it says "Applet started", but the screen is blue. When I go to Applet => Start, the message changes to "Start applet not initialized"

When I run it in the browser and set the trace to 5 in the console it says:

basic: Stopping applet ...

basic: Removed progress listener: sun.plugin.util.GrayBoxPainter@17e6a96

basic: Finding information ...

basic: Releasing classloader: sun.plugin.ClassLoaderInfo@ca8327, refcount=0

basic: Caching classloader: sun.plugin.ClassLoaderInfo@ca8327

basic: Current classloader cache size: 1

basic: Done ...

basic: Joining applet thread ...

basic: Destroying applet ...

basic: Disposing applet ...

basic: Joined applet thread ...

basic: Unregistered modality listener

basic: Quiting applet ...

basic: Registered modality listener

basic: Referencing classloader: sun.plugin.ClassLoaderInfo@ca8327, refcount=1

basic: Added progress listener: sun.plugin.util.GrayBoxPainter@1922221

basic: Loading applet ...

basic: Initializing applet ...

basic: Starting applet ...

DarkNomada at 2007-7-13 1:43:00 > top of Java-index,Java Essentials,New To Java...