quinta-feira, 6 de maio de 2010

How to add an applet to your google site

I've had a google site for some time now. I've never really put an effort to do something with it until some weeks ago, when I decided to publish some applet games I've been working on.
First thing first, I clicked on  "More Actions>Manage site>Attachments>Upload" and uploaded my jar.
Well, I always used the <applet> tag to add applets to my sites (ok, I know it is deprecated but still...), so I clicked on the HTML button to add this:
<applet
code="main.MainGameApplet"
archive="pathgui.jar"
width="300" height="100"
>
Applet Didn't Load
</applet>
Just to find that Google sites erases the applet tag!

I knew that the applet tag was deprecated, and I've already saw a google site with an applet, so I knew it was possible to do it. And, after trying a lot of things I found on the Internet, the tag that worked was this little guy:

<!--[if !IE]> Firefox and others will use outer object -->
<object classid="java:main.MainGameApplet.class"
type="application/x-java-applet"
archive="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar"
height="505" width="500" >
<!-- Konqueror browser needs the following param -->
<param name="archive" value="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar" />
<!--<![endif]-->
<!-- MSIE (Microsoft Internet Explorer) will use inner object -->
<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"
height="505" width="500" >
<param name="code" value="main.MainGameApplet" />
<param name="archive" value="http://sites.google.com/site/lucass/home/projects/path/pathgui-1.0-SNAPSHOT-jar-with-dependencies.jar" />
<strong>
This browser does not have a Java Plug-in.
<br />
<a href="http://java.sun.com/products/plugin/downloads/index.html">
Get the latest Java Plug-in here.
</a>
</strong>
</object>
<!--[if !IE]> close outer object -->
</object>
<!--<![endif]-->
And after that google sites wrapped my applet in a beautifull gadget box.