Joseph Montanez wrote:
> If your using the adapter with an empty javascript object then thats a
> no no.

That was just to simplify the example.  In reality, I wanted to override
some methods.

> I just spent an hour actraully trying to figure this out maybe I am
> doing it wrong but it works.
> 
> importPackage(java.awt);
> 
> function JMColor(r,g,b) {
>     // the same as calling super()
>     var color = JavaAdapter(Color(r,g,b));
>     // Do your contstructor stuff here
> 
>     // return the object
>     return color;
> }
> var col = new JMColor(0.75,0.5,0.5);
> print(col);
> //java.awt.Color[r=191,g=128,b=128]

AFAICT, the above code will create a new adapter class that extends
java.lang.Object, with methods taken from the instance of java.awt.Color
that was created.  An instance of the new adapter class is created, and
return and assigned to 'col'.  Is that right?

Interestingly, col.__proto__ == the java.awt.Color object created and
returned from JMColor.  That explains how the "java.awt.Color[...]"
string can be printed.

-- 
Cameron McCormack ≝ http://mcc.id.au/
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to