home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.BorderLayout;
- import java.awt.Container;
- import java.awt.Label;
-
- public class Switcher extends Applet {
- protected Applet applet;
- protected boolean appletFound = false;
- protected static String defaultNewPackage = "newawt";
- protected static String defaultOldPackage = "oldawt";
- protected static int NUMPARAMETERS = 3;
- protected static boolean DEBUG;
-
- protected void mayday(String var1) {
- ((Container)this).add("Center", new Label(var1));
- System.err.println("Switcher initialization failed: " + var1);
- }
-
- public void init() {
- Object var1 = null;
- Object var2 = null;
- String var10 = ((Applet)this).getParameter("APPLETCLASS");
- if (var10 == null) {
- this.mayday("No APPLETCLASS parameter specified");
- } else {
- if (DEBUG) {
- System.out.println("The name of the applet class we're going to try to load: " + var10);
- }
-
- String var9;
- if (this.oneDotOneIsSupported()) {
- var9 = ((Applet)this).getParameter("NEWPACKAGE");
- if (var9 == null) {
- var9 = defaultNewPackage;
- }
-
- if (DEBUG) {
- System.out.println("1.1 is supported; package name: " + var9);
- }
- } else {
- var9 = ((Applet)this).getParameter("OLDPACKAGE");
- if (var9 == null) {
- var9 = defaultOldPackage;
- }
-
- if (DEBUG) {
- System.out.println("1.1 NOT supported; package name: " + var9);
- }
- }
-
- var10 = var9 + "." + var10;
- if (DEBUG) {
- System.out.println("The fully qualified name of the applet class we're going to try to load: " + var10);
- }
-
- try {
- this.applet = (Applet)Class.forName(var10).newInstance();
- this.appletFound = true;
- if (DEBUG) {
- System.out.println("Yay! We found the applet class!");
- }
- } catch (ClassNotFoundException var5) {
- this.mayday("Couldn't find applet: " + var10);
- return;
- } catch (IllegalAccessException var6) {
- this.mayday("Is class " + var10 + " public?");
- return;
- } catch (ClassCastException var7) {
- this.mayday(var10 + " isn't an Applet!");
- return;
- } catch (InstantiationException var8) {
- this.mayday("InstantiationException while attempting to create an instance of " + var10);
- return;
- }
-
- ((Container)this).setLayout(new BorderLayout());
- ((Container)this).add("Center", this.applet);
- if (DEBUG) {
- System.out.println("Successfully loaded class " + var10);
- }
-
- try {
- this.applet.init();
- } catch (Throwable var4) {
- this.mayday("Exception when calling init() method of " + var10);
- var4.printStackTrace();
- return;
- }
-
- ((Container)this).validate();
- }
- }
-
- public void start() {
- if (this.appletFound) {
- this.applet.start();
- }
-
- if (DEBUG) {
- System.out.println(this.getAppletInfo());
- String[][] var1 = this.getParameterInfo();
-
- for(int var2 = 0; var2 < var1.length; ++var2) {
- System.out.println("Parameter #" + (var2 + 1) + ": " + var1[var2][0] + ", " + var1[var2][1] + ", " + var1[var2][2]);
- }
- }
-
- }
-
- public void stop() {
- if (this.appletFound) {
- this.applet.stop();
- }
-
- }
-
- public void destroy() {
- if (this.appletFound) {
- this.applet.destroy();
- }
-
- }
-
- public String getAppletInfo() {
- String var1 = "Applet Switcher, version 0.1, by Kathy Walrath";
- Object var2 = null;
- if (this.appletFound) {
- String var3 = this.applet.getAppletInfo();
- if (var3 != null) {
- var1 = var1 + ", running applet: \n" + var3;
- }
- }
-
- return var1;
- }
-
- public String[][] getParameterInfo() {
- int var1 = NUMPARAMETERS;
- int var2 = 0;
- int var3 = 0;
- String[][] var5 = null;
- String[] var6 = new String[]{"appletClass", "name", "the name of a class"};
- String[] var7 = new String[]{"oldPackage", "name", "the old applet's package"};
- String[] var8 = new String[]{"newPackage", "name", "the new applet's package"};
- if (this.appletFound) {
- var5 = this.applet.getParameterInfo();
- }
-
- if (var5 != null) {
- var2 = var5.length;
- var1 += var2;
- }
-
- String[][] var4;
- for(var4 = new String[var1][]; var3 < var2; ++var3) {
- var4[var3] = var5[var3];
- }
-
- var4[var3++] = var6;
- var4[var3++] = var7;
- var4[var3] = var8;
- return var4;
- }
-
- protected boolean oneDotOneIsSupported() {
- try {
- Class var1 = Class.forName("java.awt.AWTEvent");
- if (DEBUG) {
- System.out.println("1.1 class " + var1.getName() + " exists.");
- }
-
- var1 = Class.forName("java.awt.event.ActionEvent");
- if (DEBUG) {
- System.out.println("1.1 class " + var1.getName() + " exists.");
- }
-
- System.out.println("This seems to be a 1.1 browser/viewer!");
- return true;
- } catch (Throwable var2) {
- System.out.println("This browser/viewer doesn't seem to support the 1.1 AWT API.");
- return false;
- }
- }
- }
-