Embedding Applet into the center of fullscreen API
Code:
public String a;
public Applet applet;
Crawler crawler = new Crawler();
HashMap parameters = crawler.getParameters();
URLClassLoader classLoader;
RGBFinder bot = new RGBFinder();
int world = Methods.random(1, 50);
String base = "http://world" + world + ".runescape.com";
public EnhancedUI(){
try {
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
}
initApplet();
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setUndecorated(true);
frame.setResizable(false);
frame.setLayout(null);
frame.validate();
getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(frame);
appletResize(500,400);
applet.setLocation(200,200);
frame.add(applet);
}
private void initApplet() {
try {
String jarName = "loader.jar";
String className = "loader";
URL[] appletURL = { new URL(base + "/" + jarName) };
classLoader = new URLClassLoader(appletURL);
Class loader = classLoader.loadClass(className);
applet = (Applet) loader.newInstance();
applet.setStub(this);
applet.init();
applet.start();
} catch (InstantiationException ex) {
Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
} catch (MalformedURLException ex) {
Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
public boolean isActive() {
return false; //To change body of implemented methods use File | Settings | File Templates.
}
public URL getDocumentBase() {
try {
return new URL(base);
} catch (MalformedURLException ex) {
Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
public URL getCodeBase() {
try {
return new URL(base);
} catch (MalformedURLException ex) {
Logger.getLogger(EnhancedUI.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
public String getParameter(String name) {
return (String) parameters.get(name);
}
public AppletContext getAppletContext() {
return null;
}
public void appletResize(int width, int height) {
applet.setSize(width, height);
}
For some reason, when I run this program, I see the fullscreen, and the can hear the Applet's sound, but not the visual counterpart of the Applet. What is wrong? Thanks!