I would like to set the color properties of a bean through a script. Unfortunately the bean wants a java color like ‘new Color()’…
Can anybody tell me how to archieve this?
I would like to set the color properties of a bean through a script. Unfortunately the bean wants a java color like ‘new Color()’…
Can anybody tell me how to archieve this?
try this:
var jcolor = new java.awt.Color(255,0,255);
elements.mybean.backgroundColor = jcolor
Jan, when I do this
var jcolor = new java.awt.Color(10,10,10);
elements.seperator.background = jcolor;
the message is: java.lang.IllegalArgumentException: Color parameter outside of expected range: Red Green Blue
When I do this:
var jcolor = new java.awt.Color(0,0,0);
elements.seperator.background = jcolor;
The result is a black line but any other thing than 0,0,0 will give an error…
It seems to use the float variant constructor… which accept 0.0-1.0
you could try this:
var jcolor = new java.awt.Color(parseInt(10),parseInt(10),parseInt(10));
```to make sure the integer variant is used.
Nope, but you gave me a direction. We have to use a floating value here so it is going to be:
var jcolor = new java.awt.Color(0.04, 0.04, 0.04);
The value lies between 0 and 1…
Jan, does this mean that we can call more java functions methods etc from within Servoy?
Thanks
yes, but be careful, it easy to create mem leaks
globals.frame = new javax.swing.JFrame('test frame');
globals.frame.setVisible(true);
creates a instant mem leak if you don’t clear globals.frame afterwards with:
globals.frame = null;
we strongly recomment to stick with JavaScript, unless you are an expirienced Java programmer
You must have read my mind because your code is exactly what I was experimenting with
(unfortunately I receive an error on the use javax, not recognized!)
And yes, I will be carefull. So in fact it would be better to do this in a plugin?
For Java plugins are prefered.