LWJGL Forum

Programming => General Java Game Development => Topic started by: plan_rich on March 26, 2010, 19:21:22

Title: LWJGL Applet with Appletloader - no JavaScript to Java communication
Post by: plan_rich on March 26, 2010, 19:21:22
hello there,

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

Code: [Select]
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).

Code: [Select]
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?

Title: Re: LWJGL Applet with Appletloader - no JavaScript to Java communication
Post by: kappa on March 27, 2010, 14:36:10
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.
Title: Re: LWJGL Applet with Appletloader - no JavaScript to Java communication
Post by: kappa on March 27, 2010, 14:43:02
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?
Title: Re: LWJGL Applet with Appletloader - no JavaScript to Java communication
Post by: spasi on March 27, 2010, 19:42:25
I've tried this before, AppletLoader.getApplet() works iirc.