admin管理员组文章数量:1023213
I know from this page that I can select a method like this:
API["test(Integer[])"](1);
How do I do this for constructors? In particular, I'm trying to instantiate a java.awt.Color
from Nashorn:
var highlightColor = new java.awt.Color(1, 1, 128/255, 1);
I get the following error: Can't unambiguously select between fixed arity signatures [(float, float, float, float), (int, int, int, int)] of the method java.awt.Color. for argument types [java.lang.Integer, java.lang.Integer, java.lang.Double, java.lang.Integer]
I've tried this:
var highlightColor = new java.awt.Color["(float,float,float,float)"](1, 1, 128/255, 1);
But that gives me this error: Caused by: :52 TypeError: null is not a function
I know from this page that I can select a method like this:
API["test(Integer[])"](1);
How do I do this for constructors? In particular, I'm trying to instantiate a java.awt.Color
from Nashorn:
var highlightColor = new java.awt.Color(1, 1, 128/255, 1);
I get the following error: Can't unambiguously select between fixed arity signatures [(float, float, float, float), (int, int, int, int)] of the method java.awt.Color. for argument types [java.lang.Integer, java.lang.Integer, java.lang.Double, java.lang.Integer]
I've tried this:
var highlightColor = new java.awt.Color["(float,float,float,float)"](1, 1, 128/255, 1);
But that gives me this error: Caused by: :52 TypeError: null is not a function
Share Improve this question edited May 23, 2017 at 11:59 CommunityBot 11 silver badge asked Dec 9, 2014 at 21:23 David StruckDavid Struck 1572 silver badges9 bronze badges3 Answers
Reset to default 4We added this functionality, but it will only be available with Java 8u40. The exact syntax is java.awt["Color(int, int, int)"]
(the signature is part of the last name ponent, consistent with how it works on method names). You can try it out with early access releases of 8u40 at this time (it's scheduled for release in March 2015).
You need to make sure you're passing in 4 integers (or floats in this case), try this.
var highlightColor = new java.awt.Color(1.0, 1.0, 128/255, 1.0);
Pass either 4 ints or 4 floats
var highlightColor = new java.awt.Color(255, 255, 128, 255);
OR
var highlightColor = new java.awt.Color(1.0, 1.0, 128/255, 1.0);
I know from this page that I can select a method like this:
API["test(Integer[])"](1);
How do I do this for constructors? In particular, I'm trying to instantiate a java.awt.Color
from Nashorn:
var highlightColor = new java.awt.Color(1, 1, 128/255, 1);
I get the following error: Can't unambiguously select between fixed arity signatures [(float, float, float, float), (int, int, int, int)] of the method java.awt.Color. for argument types [java.lang.Integer, java.lang.Integer, java.lang.Double, java.lang.Integer]
I've tried this:
var highlightColor = new java.awt.Color["(float,float,float,float)"](1, 1, 128/255, 1);
But that gives me this error: Caused by: :52 TypeError: null is not a function
I know from this page that I can select a method like this:
API["test(Integer[])"](1);
How do I do this for constructors? In particular, I'm trying to instantiate a java.awt.Color
from Nashorn:
var highlightColor = new java.awt.Color(1, 1, 128/255, 1);
I get the following error: Can't unambiguously select between fixed arity signatures [(float, float, float, float), (int, int, int, int)] of the method java.awt.Color. for argument types [java.lang.Integer, java.lang.Integer, java.lang.Double, java.lang.Integer]
I've tried this:
var highlightColor = new java.awt.Color["(float,float,float,float)"](1, 1, 128/255, 1);
But that gives me this error: Caused by: :52 TypeError: null is not a function
Share Improve this question edited May 23, 2017 at 11:59 CommunityBot 11 silver badge asked Dec 9, 2014 at 21:23 David StruckDavid Struck 1572 silver badges9 bronze badges3 Answers
Reset to default 4We added this functionality, but it will only be available with Java 8u40. The exact syntax is java.awt["Color(int, int, int)"]
(the signature is part of the last name ponent, consistent with how it works on method names). You can try it out with early access releases of 8u40 at this time (it's scheduled for release in March 2015).
You need to make sure you're passing in 4 integers (or floats in this case), try this.
var highlightColor = new java.awt.Color(1.0, 1.0, 128/255, 1.0);
Pass either 4 ints or 4 floats
var highlightColor = new java.awt.Color(255, 255, 128, 255);
OR
var highlightColor = new java.awt.Color(1.0, 1.0, 128/255, 1.0);
本文标签: javaNashorn How to select constructor to invokeStack Overflow
版权声明:本文标题:java - Nashorn: How to select constructor to invoke - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745525638a2154512.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论