I need to contain an Applet in my application. I have tried to do this by embedding the applet as a StreamResource, as in
[url]
[/url]
and then construct the input stream as html as I would in a servlet. So I have something like:
public class AppletSource implements StreamResource.StreamSource {
public InputStream getStream() {
StringBuffer buf = new StringBuffer();
.....
.....
buf.append("<PARAM NAME=\"type\" VALUE=\"application/x-java-applet;version=1.5.0\">");
buf.append("<EMBED type=\"application/x-java-applet;version=1.5.0\"");
buf.append("width=\"100%\" height=\"100%\" align=\"baseline\"");
.....
.....
InputStream in = new ByteArrayInputStream(buf.toString().getBytes() );
return in;
Then inside the window I call
StreamResource.StreamSource appletSource = new AppletSource(uName,loc);
StreamResource appletResource = new StreamResource(appletSource,"appletname.applet",application);
....
layout.addComponent(embed);
setLayout(layout);
But it doesn’t work, and only a blank screen appears. In fact, when I try the image example from the above page, it doesn’t work either. There are no exceptions thrown, and it seems the getStream() method is never even called.
Is there something I should add to my code to make it work? Also if there is a better way to include an applet I’d appreciate any advice.