First, Applet Source Code (TMIN_JS.JAVA)
// Importations
Import java.awt.graphics;
Import java.awt.event;
// LiveConnect ... for JavaScript
Import Netscape.javascript.jsobject;
Public Class Tmin_JS Extends Java.applet.applet {
// Variables
// initialisation de l'applet
Public void init () {//Methode init ()
}
// debiner l'applet
Public void Paint (Graphics G) {//Methode Paint ()
g.drawstring ("Click Here ...", 5, 10);
}
// mouse down
Public Boolean MouseDown (Event E, INT X, INT Y) {
Try {// create jsobject
JSObject.getWindow (this). Eval ("JavaScript: ale
RT ('Tmin_JS Click "
"x =" x "y =" y ")");
}
Catch (Exception EX) {// Error On Create JSObject
ShowStatus ("Error Call JavaScript Err =" EX);
}
Return True;
}
}
Second, the attention of attention
(1) When calling the JavaScipt function, add this line:
JSObject.getWindow (this). Eval ("JavaScript: ...");
(2) To bring JSObject reference:
Import Netscape.javascript.jsobject;
(3) Tagging "MayScript" tag when defining applets