rendered paste body// add the downloaded jars and natives to classpath
URLClassLoader classLoader = updateClassPath(path);
// switch to LWJGL Applet
switchApplet(classLoader);
protected void updateClassPath(String path) throws Exception {
state = STATE_UPDATING_CLASSPATH;
percentage = 95;
Class[] parameters = new Class[] {URL.class};
// modify class path by adding downloaded jars to it
URL[] urls = new URL[urlList.length];
for (int i = 0; i < urlList.length; i++) {
urls[i] = new URL("file:" + path + getFileName(urlList[i]));
}
URLClassLoader loader = new URLClassLoader(urls, getClass().getClassLoader());
if (debugMode) {
sleep(2000);
}
// add natives files path to native class path
System.setProperty("org.lwjgl.librarypath", path + "natives");
// Make sure jinput knows about the new path too
System.setProperty("net.java.games.input.librarypath", path + "natives");
return loader;
}
protected synchronized void switchApplet(ClassLoader loader) throws Exception {
state = STATE_SWITCHING_APPLET;
percentage = 100;
if(debugMode) {
sleep(2000);
}
Class appletClass = loader.loadClass(getParameter("al_main"));
lwjglApplet = (Applet) appletClass.newInstance();
lwjglApplet.setStub(this);
lwjglApplet.setSize(getWidth(), getHeight());
setLayout(new BorderLayout());
add(lwjglApplet);
state = STATE_INITIALIZE_REAL_APPLET;
lwjglApplet.init();
state = STATE_START_REAL_APPLET;
lwjglApplet.start();
// fix for issue with applet not showing up in firefox
setVisible(false);
setVisible(true);
}