Java Code Examples for java.applet.AppletStub

The following are top voted examples for showing how to use java.applet.AppletStub. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: onecmdb   File: AppletLaunch.java   View source code 6 votes vote down vote up
public void run() {

   try {
      Class cls = Class.forName(loadAppletName);
      JApplet app = (JApplet)cls.newInstance();
      app.setStub((AppletStub)this);
      app.init();
      
     
      getContentPane().add("Center", app);
      loadApplet = app;
      validate();
     
      if(isStarted) {
     	 loadApplet.start();
      }
      validate();
   } catch (Throwable e) {
  	 loadApplet = null;
      AppletLogger.showError("Exception:", e);
      
      e.printStackTrace();
      validate();
   }
   System.out.println("Thread end");
}
 
Example 2
Project: OneCMDBwithMaven   File: AppletLaunch.java   View source code 6 votes vote down vote up
public void run() {

   try {
      Class cls = Class.forName(loadAppletName);
      JApplet app = (JApplet)cls.newInstance();
      app.setStub((AppletStub)this);
      app.init();
      
     
      getContentPane().add("Center", app);
      loadApplet = app;
      validate();
     
      if(isStarted) {
     	 loadApplet.start();
      }
      validate();
   } catch (Throwable e) {
  	 loadApplet = null;
      AppletLogger.showError("Exception:", e);
      
      e.printStackTrace();
      validate();
   }
   System.out.println("Thread end");
}
 
Example 3
Project: rsc   File: GameClient.java   View source code 6 votes vote down vote up
private static Applet loadClientApplet(URL resourceURL, URL serverURL, RSAPublicKey key, boolean members) throws GameClientModificationException {
    LOG.info("Loading client applet, server: {}, resources: {}", serverURL, resourceURL);

    final Class<Applet> clazz = GameClient.loadClientAppletClass(resourceURL, key);

    final AppletStub stub = new MockAppletStub(resourceURL, serverURL, GameClient.buildParameterMap(members));

    try {
        final Applet applet = clazz.getConstructor(GameClientCallback.class).newInstance(stub);
        applet.setStub(stub);

        return applet;
    }
    catch (ReflectiveOperationException e) {
        throw new GameClientModificationException("Unable to instantiate client", e);
    }
}
 
Example 4
Project: NotifyTools   File: Beans.java   View source code 5 votes vote down vote up
private static AppletStub getAppletStub(final AppletContext context, final URL codeBase, final URL docBase) {

        return new AppletStub() {
            public boolean isActive() {
                return true;
            }

            public URL getDocumentBase() {
                return docBase;
            }

            public URL getCodeBase() {
                return codeBase;
            }

            public String getParameter(String name) {
                // Applet beans have no params.
                return null;
            }

            public AppletContext getAppletContext() {
                return context;
            }

            public void appletResize(int width, int height) {
                // Do nothing.
            }
        };
    }
 
Example 5
Project: Vanilla-Injection   File: JarClassLoader.java   View source code 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 6
Project: hccd   File: JarClassLoader.java   View source code 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 7
Project: MPL   File: JarClassLoader.java   View source code 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 8
Project: icedtea-web   File: Launcher.java   View source code 5 votes vote down vote up
/**
 * Create an AppletInstance.
 *
 * @param file the JNLP file
 * @param enableCodeBase whether to add the codebase URL to the classloader
 * @param cont container where to put applet
 * @return applet
 * @throws net.sourceforge.jnlp.LaunchException if deploy unrecoverably die
 */
 //FIXME - when multiple applets are on one page, this method is visited simultaneously
//and then appelts creates in little bit strange manner. This issue is visible with
//randomly showing/notshowing spalshscreens.
//See also PluginAppletViewer.framePanel
protected  AppletInstance createApplet(JNLPFile file, boolean enableCodeBase, Container cont) throws LaunchException {
     AppletInstance appletInstance = null;
     try {
        JNLPClassLoader loader = JNLPClassLoader.getInstance(file, updatePolicy, enableCodeBase);

        if (enableCodeBase) {
            loader.enableCodeBase();
        } else if (file.getResources().getJARs().length == 0) {
            throw new ClassNotFoundException("Can't do a codebase look up and there are no jars. Failing sooner rather than later");
        }

        ThreadGroup group = Thread.currentThread().getThreadGroup();

        // appletInstance is needed by ServiceManager when looking up 
        // services. This could potentially be done in applet constructor
        // so initialize appletInstance before creating applet.
        if (cont == null) {
             appletInstance = new AppletInstance(file, group, loader, null);
         } else {
             appletInstance = new AppletInstance(file, group, loader, null, cont);
         }

        loader.setApplication(appletInstance);

        // Initialize applet now that ServiceManager has access to its
        // appletInstance.
        String appletName = file.getApplet().getMainClass();
        Class<?> appletClass = loader.loadClass(appletName);
        Applet applet = (Applet) appletClass.newInstance();
        applet.setStub((AppletStub)cont);
        // Finish setting up appletInstance.
        appletInstance.setApplet(applet);
        appletInstance.getAppletEnvironment().setApplet(applet);
        
        setContextClassLoaderForAllThreads(appletInstance.getThreadGroup(), appletInstance.getClassLoader());

        return appletInstance;
    } catch (Exception ex) {
        throw launchError(new LaunchException(file, ex, R("LSFatal"), R("LCInit"), R("LInitApplet"), R("LInitAppletInfo")), appletInstance);
    }
}
 
Example 9
Project: openbeans   File: Beans.java   View source code 5 votes vote down vote up
private static AppletStub getAppletStub(final AppletContext context, final URL codeBase, final URL docBase) {

        return new AppletStub() {
            public boolean isActive() {
                return true;
            }

            public URL getDocumentBase() {
                return docBase;
            }

            public URL getCodeBase() {
                return codeBase;
            }

            public String getParameter(String name) {
                // Applet beans have no params.
                return null;
            }

            public AppletContext getAppletContext() {
                return context;
            }

            public void appletResize(int width, int height) {
                // Do nothing.
            }
        };
    }
 
Example 10
Project: terramaster   File: JarClassLoader.java   View source code 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 11
Project: iCashBook   File: JarClassLoader.java   View source code 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 12
Project: cn1   File: Beans.java   View source code 5 votes vote down vote up
private static AppletStub getAppletStub(final AppletContext context, final URL codeBase, final URL docBase) {

        return new AppletStub() {
            public boolean isActive() {
                return true;
            }

            public URL getDocumentBase() {
                return docBase;
            }

            public URL getCodeBase() {
                return codeBase;
            }

            public String getParameter(String name) {
                // Applet beans have no params.
                return null;
            }

            public AppletContext getAppletContext() {
                return context;
            }

            public void appletResize(int width, int height) {
                // Do nothing.
            }
        };
    }
 
Example 13
Project: freeVM   File: Beans.java   View source code 5 votes vote down vote up
private static AppletStub getAppletStub(final AppletContext context, final URL codeBase, final URL docBase) {

        return new AppletStub() {
            public boolean isActive() {
                return true;
            }

            public URL getDocumentBase() {
                return docBase;
            }

            public URL getCodeBase() {
                return codeBase;
            }

            public String getParameter(String name) {
                // Applet beans have no params.
                return null;
            }

            public AppletContext getAppletContext() {
                return context;
            }

            public void appletResize(int width, int height) {
                // Do nothing.
            }
        };
    }
 
Example 14
Project: app55-java   File: Beans.java   View source code 5 votes vote down vote up
private static AppletStub getAppletStub(final AppletContext context, final URL codeBase, final URL docBase)
{

	return new AppletStub() {
		public boolean isActive()
		{
			return true;
		}

		public URL getDocumentBase()
		{
			return docBase;
		}

		public URL getCodeBase()
		{
			return codeBase;
		}

		public String getParameter(String name)
		{
			// Applet beans have no params.
			return null;
		}

		public AppletContext getAppletContext()
		{
			return context;
		}

		public void appletResize(int width, int height)
		{
			// Do nothing.
		}
	};
}
 
Example 15
Project: hypergraphdb-android   File: Beans.java   View source code 5 votes vote down vote up
private static AppletStub getAppletStub(final AppletContext context, final URL codeBase, final URL docBase) {

        return new AppletStub() {
            public boolean isActive() {
                return true;
            }

            public URL getDocumentBase() {
                return docBase;
            }

            public URL getCodeBase() {
                return codeBase;
            }

            public String getParameter(String name) {
                // Applet beans have no params.
                return null;
            }

            public AppletContext getAppletContext() {
                return context;
            }

            public void appletResize(int width, int height) {
                // Do nothing.
            }
        };
    }
 
Example 16
Project: pdfxtk   File: Applet.java   View source code 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));
 }
 
Example 17
Project: Parabot   File: ServerProvider.java   View source code 5 votes vote down vote up
public AppletStub getStub() {
    return null;
}