invoke a java method with int arguments from javascript/rhino -
how can invoke overloaded java method integer , float javascript/rhino?
for example, how can invoke javascript/rhino java java.awt.color(int,int,int) constructor? have dealt next snipets not work:
var integer = java.lang.integer; var color = new java.awt.color(12,58,92); // invokes java.awt.color(float,float,float) , throws wrapped java.lang.illegalargumentexception: color parameter outside of expected range: red green blue. var color = new java.awt.color(new integer(12), new integer(58), new integer(92) // invokes java.awt.color(float,float,float) , throws exception var color = new color(integer.valueof(12),integer.valueof(200),integer.valueof(80)); // invokes java.awt.color(float,float,float) , throws exception
the mechanism documented here. can access constructor following syntax:
js> new java.awt.color['(int,int,int)'](1,2,3); // no spaces allowed! java.awt.color[r=1,g=2,b=3]
or
js> java.awt.color['(java.awt.color.colorspace,float[],float)'] function <init>(java.awt.color.colorspace,float[],float)() { [native code, arity=0] }
Comments
Post a Comment