LWJGL Applet with Appletloader - no JavaScript to Java communication

Started by plan_rich, March 26, 2010, 19:21:22

Previous topic - Next topic

plan_rich

hello there,

i recently setup a lwjgl java applet and wanted to call method x from my applet class using javascript.
With the command:

document.myApplet.x()


it is not possible because if you use the org.lwjgl.util.applet.AppletLoader, the browser searches for the method x in the AppletLoader class (which does not exist).

org.my.package.to.class.MyStaticClass.staticMethodX()


is also not possible (mybe because the actual applet, is loaded seperatly to the ClassLoader in the AppletLoader class?)

What would you recommend to make this possible?


kappa

hmm, this is an interesting issue. Don't think I can think of a solution atm but one easy way would be to just use a custom AppletLoader class and have it call the methods in your main class. Will have to think about this.

you can do Java to JavaScript (other way round) communication fine though. So you could for example set a javascript boolean and have the applet poll it every so often to know when to launch a method.

kappa

oh, looking at the applet loader I just came across the AppletLoader.getApplet() method, can't you use that to get your main class and call methods from it?

spasi

I've tried this before, AppletLoader.getApplet() works iirc.