Hello Guest

LWJGL Applet with Appletloader - no JavaScript to Java communication

  • 3 Replies
  • 6240 Views
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?


*

Offline kappa

  • *****
  • 1319
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.
« Last Edit: March 27, 2010, 14:37:55 by javalwjgl »

*

Offline kappa

  • *****
  • 1319
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?

*

Offline spasi

  • *****
  • 2225
    • WebHotelier
I've tried this before, AppletLoader.getApplet() works iirc.