Java Example Program/ Sample Source Code
import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
public class IsActive_AppletStub implements AppletStub{
private Hashtable<String, String> hashtable;
private Applet applet;
public IsActive_AppletStub(String args[], Applet a) {
applet = a;
hashtable = new Hashtable<String, String>();
for (int i = 0; i < args.length; i++) {
try {
StringTokenizer parser = new StringTokenizer(args[i], "=");
String name = parser.nextToken().toString();
String value = parser.nextToken("\"").toString();
value = value.substring(1);
hashtable.put(name, value);
} catch (NoSuchElementException e) {
e.printStackTrace();
}
}
}
public void appletResize(int width, int height) {
applet.resize(width, height);
}
public AppletContext getAppletContext() {
return null;
}
public java.net.URL getCodeBase() {
String host;
if ((host = getParameter("host")) == null) {
try {
host = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
java.net.URL url = null;
try {
url = new java.net.URL("file://" + host);
} catch (Exception e) {
}
return url;
}
public java.net.URL getDocumentBase() {
return getCodeBase();
}
public String getParameter(String param) {
return (String) hashtable.get(param);
}
public boolean isActive() {
return true;
}
} |
|
|