java.applet.AppletStub Java Examples

The following examples show how to use java.applet.AppletStub. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JarClassLoader.java    From hccd with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Call this method to initialize an applet from your launcher class
 * <code>MyAppletLauncher.init()</code> method.
 *
 * @param sClass class name in form "MyClass" for default package
 * or "com.abc.MyClass" for class in some package
 *
 * @param appletParent parent applet from a launcher.
 *
 * @throws Throwable wrapper for many exceptions thrown while applet
 * instantiation and calling init() method.
 */
public void initApplet(String sClass, final JApplet appletParent) throws Throwable {
    Class<?> clazz = loadClass(sClass);
    logInfo(LogArea.CONFIG, "initApplet() --> %s.init(); Loader: %s", sClass, clazz.getClassLoader());
    applet = (JApplet)clazz.newInstance();
    applet.setStub(new AppletStub() {
        @Override
        public boolean isActive() {
            return appletParent.isActive();
        }
        @Override
        public URL getDocumentBase() {
            return appletParent.getDocumentBase();
        }
        @Override
        public URL getCodeBase() {
            return appletParent.getCodeBase();
        }
        @Override
        public String getParameter(String name) {
            return appletParent.getParameter(name);
        }
        @Override
        public AppletContext getAppletContext() {
            return appletParent.getAppletContext();
        }
        @Override
        public void appletResize(int width, int height) {
            appletParent.resize(width, height);
        }
    });
    applet.init();
    appletParent.setContentPane(applet.getContentPane());
}
 
Example #2
Source File: Applet.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
public Applet() {
   if(STANDALONE)
     setStub(new AppletStub() {
  public void appletResize(int width, int height) {}
  
  public AppletContext getAppletContext() {
    return null;
  }
  
  public URL getCodeBase() {
    return null;
  }
  
  public URL getDocumentBase() {
    return null;
  }
  
  public String getParameter(String key) {
    return (String)params.get(key);
  }
  
  public boolean isActive() {
    return active;
  }
});
   Preferences.addStore(new AppletPreferences(this));

   setBackground(new Color(0xC0C0C0));
 }