Example #1
0
  /**
   * Load the applet into memory. Runs in a seperate (and interruptible) thread from the rest of the
   * applet event processing so that it can be gracefully interrupted from things like HotJava.
   */
  @SuppressWarnings("deprecation")
  private void runLoader() {
    if (status != APPLET_DISPOSE) {
      showAppletStatus("notdisposed");
      return;
    }

    dispatchAppletEvent(APPLET_LOADING, null);

    // REMIND -- might be cool to visually indicate loading here --
    // maybe do animation?
    status = APPLET_LOAD;

    // Create a class loader
    loader = getClassLoader(getCodeBase(), getClassLoaderCacheKey());

    // Load the archives if present.
    // REMIND - this probably should be done in a separate thread,
    // or at least the additional archives (epll).

    String code = getCode();

    // setup applet AppContext
    // this must be called before loadJarFiles
    setupAppletAppContext();

    try {
      loadJarFiles(loader);
      applet = createApplet(loader);
    } catch (ClassNotFoundException e) {
      status = APPLET_ERROR;
      showAppletStatus("notfound", code);
      showAppletLog("notfound", code);
      showAppletException(e);
      return;
    } catch (InstantiationException e) {
      status = APPLET_ERROR;
      showAppletStatus("nocreate", code);
      showAppletLog("nocreate", code);
      showAppletException(e);
      return;
    } catch (IllegalAccessException e) {
      status = APPLET_ERROR;
      showAppletStatus("noconstruct", code);
      showAppletLog("noconstruct", code);
      showAppletException(e);
      // sbb -- I added a return here
      return;
    } catch (Exception e) {
      status = APPLET_ERROR;
      showAppletStatus("exception", e.getMessage());
      showAppletException(e);
      return;
    } catch (ThreadDeath e) {
      status = APPLET_ERROR;
      showAppletStatus("death");
      return;
    } catch (Error e) {
      status = APPLET_ERROR;
      showAppletStatus("error", e.getMessage());
      showAppletException(e);
      return;
    } finally {
      // notify that loading is no longer going on
      dispatchAppletEvent(APPLET_LOADING_COMPLETED, null);
    }

    // Fixed #4508194: NullPointerException thrown during
    // quick page switch
    //
    if (applet != null) {
      // Stick it in the frame
      applet.setStub(this);
      applet.hide();
      add("Center", applet);
      showAppletStatus("loaded");
      validate();
    }
  }