A new Java-Swing Student ask for help

I have a question that I hope anyone here could help me out.

I have learned Java at school but without learning Swing.

I got a problem that if the applet using Swing,

IE(5.5) and Netscapt(4.7) can't find the applet even

though I put all the necessary files into the same folder.

I even tried to use the sample files, including the .html, come with the book without modifying them. It still doesn't work. It work with appletviewer, though.

If I change the .java file into a .java without Swing, it works with any browers.

Here is the .java and .html files come with the book :

import javax.swing.JApplet; // import class JApplet

import java.awt.Graphics;// import class Graphics

public class WelcomeApplet extends JApplet {

public void paint( Graphics g )

{

g.drawString( "Welcome to Java Programming!", 25, 25 );

}

}

The .html file as below:

<html>

<applet code="WelcomeApplet.class" width=300 height=30>

</applet>

</html>

I know this is a simple question but I really can't figure it out. Hope anyone here could give me any advise.

Thanks a lot.

[1220 byte] By [ericbfdl] at [2007-9-26 2:03:58]
# 1
there is some sort of plug in that some browsers need to understand swing. don't know the details
arcosh at 2007-6-29 8:47:22 > top of Java-index,Archived Forums,Java Programming...
# 2

You'll need a plugin from Sun, now I'm not sure if that includes swing or not, I'd think it does. If it doesn't you can download the swing package from somewhere on this site.

IE as installed is just compatable with jre1.1 which doesnt include swing, that's why you need to download this other stuff for it to work.

Hoju at 2007-6-29 8:47:22 > top of Java-index,Archived Forums,Java Programming...
# 3

If you installed the 1.3 SDK, I think it installs the plug-in.

Try this for the html:

<html>

<head>

<title>Applet Test</title>

</head>

<body>

<object width="300" height="30" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93">

<param name="code" value="WelcomeApplet.class">

<param name="type" value="application/x-java-applet;version=1.1">

</object>

</body>

</html>

alee1010 at 2007-6-29 8:47:22 > top of Java-index,Archived Forums,Java Programming...
# 4
How did you install SWNIG to JDK ?
javamanz at 2007-6-29 8:47:22 > top of Java-index,Archived Forums,Java Programming...
# 5
http://java.sun.com/products/plugin/That's the plugin, get 1.3.1 Install swing to the jdk? the jdk comes with swing.
Hoju at 2007-6-29 8:47:22 > top of Java-index,Archived Forums,Java Programming...
# 6

You might find it simplest to download the html converter from SUN, if you're going to be getting the plugin. The HTML converter changes your html for you, and tells any browser that opens your web page to get the plugin so it can see your applet.

http://java.sun.com/products/plugin/converter.html

mnkyby79 at 2007-6-29 8:47:22 > top of Java-index,Archived Forums,Java Programming...
# 7
Thanks all of you. It really did help, especially alee1010's code. I got it worked with IE without installing any plug-in.Thanks a lot.
ericbfdl at 2007-6-29 8:47:22 > top of Java-index,Archived Forums,Java Programming...