2. This is tricky and almost undocumented and works this way:
a Java class works like an ActiveX control in IE and IE knows how to
manage it relying on JavaBean design patterns (with a few modifications),
that's to say:
- only public methods are used and no polymorphism is supported
- to access properties you must supply getX() and/or setX() methods
(getX() for readable props, setX() for writable ones, both for R/W props)
(thus you can either use the access methods or the property from JS)
- values are converted on the fly: JS strings to String, JS numbers to
int, float... or whatever, JS objects to any Java object indicated,
Java objects are wrapped in a COM Variant to old their dispatch
interface
- the bean class can generate events implementing a pair of methods
addXListener(XListener) and removeXListener(XListener); you have
to define an interface XListener (of course you can use the ones
in java.awt.event.* if they suits your need) which extends
java.util.EventListener;
the abstract methods in the interface should return void and accept an
XEvent
as parameter (which extends java.util.EventObject)
Once you have setup those 3 beans, you use them this way:
- embed the applet (well, it needs not be an Applet actually, it can be any
java.awt.Component - if it must be rendered graphically - or any class
- if no display is needed) using the