24 July 2009

Embedding Applets in a Web page - 2

Setup the WampServer as explained here
-----------------TestApplet2.java-----------------
import javax.swing.*;
public class TestApplet2 extends JApplet {
public void init() {
add (new JLabel("Hello World", JLabel.CENTER));
}
}
-------------------------------------------------------
-----------------------test2.html-----------------------
<OBJECT
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH="170"
HEIGHT="70"
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2_05-windows-i586.cab#Version=1,4,2,5">
<PARAM NAME=CODE VALUE="TestApplet2.class">
<PARAM NAME=CACHE_OPTION VALUE="plugin">
<PARAM NAME=CACHE_ARCHIVE VALUE="TestApplet2.class">

<COMMENT>
<EMBED
TYPE="application/x-java-applet;version=1.4.2"
CODE="TestApplet2.class"
CACHE_OPTION="plugin"
CACHE_ARCHIVE="TestApplet2.class"
WIDTH="170"
HEIGHT="70">
</EMBED>
</COMMENT>
</OBJECT>
-------------------------------------------------------

-------------------------------------------------------
1. Save TestApplet2.java and test2.html inside the website's home page
2. Make sure JRE is installed in the machine.
3. javac TestApplet2.java
4. http://localhost/test2.html
5. appletviewer -classic test2.html
-------------------------------------------------------

Reference:
Embedding Applets in a Web page

No comments:

Post a Comment