Passing Value from Java Applet to JavaScript
in
Integration and Hardware
•
7 months ago
Hello Everyone,
I have spent hours researching this question and am stumped- Also I am new to JS. I have an applet programmed using processing and all I want to do is pass one number from the applet to JS.
For instance, if I have a method that returns an int, how do I send that int to a JS alert for instance.
Applet
public class CIGame_130316{
int x = 5;
int getValue(){
return x;
}
}
JS:
<script type="text/javascript">
/* <![CDATA[ */
var attributes = { id:'mathApplet',
code: 'CIGAME_130316.class',
archive: 'CIGAME_130316.jar,gifAnimation.jar,core.jar',
width: 450,
height: 450,
};
var parameters = {
image: 'loading.gif',
centerimage: 'true',
};
var version = '1.5';
deployJava.runApplet(attributes, parameters, version);
/* ]]> */
</script>
Then I have tried to create variables, such as:
var G = mathApplet.getValue();
alert(G);
I have found some references on the matter and tried to follow their directions. I cannot find the package jstojava and have had no luck figuring out how to reference methods within an applet from JS.
Can someone please post some processing code and some html code so I can see explicitly how this is supposed to work? I
I truly appreciate your patience- I am quite new to JS.
1