As you can see in my postings, L&F, skins and UI-properties are keeping me busy.
I’ve found in the manual the application.setUIProperty:
Sets the template directory skin property when deployed to Servoy Web Client; can
be used to set javax.swing.UIDefaults properties when deployed to Servoy Smart
Client; the function must be called as part of the on open method selected in the
Solution Settings dialog.
// setting a UIDefault property for Servoy Smart Client
application.setUIProperty(“ToolTip.hideAccelerator”, true);
So I did like described in the manual. I created a global method onOpenSolution:
It returns 'BUTTON" as expected. So it is a button.
On open of the solution the application asks for the colors and font, but my button doesn’t have the expected foreground, background and font.
Am I doing something wrong?
I’m not using any specific L&F (is standard) or skin or style.
And of course I using the smart client (I tested client and developer)
application.setUIProperty('Button.background', application.showColorChooser())
```Are you sure that this is correct?
Imho you are calling the colorChooser and not setting a color...
Well, You’re doing Java now, so you at least need to supply Java objects:
Button is a Servoy object, not a Swing object.
And have you tried to put “java.awt.Color.RED” into a variable and see what kind of object is created? Seems to me you at least need to add “Packages.” in front of it.
Am I using the setUIProperty like I should or am I completely wrong?
It is hard to give my solution a personal touch.
I tried the SkinLF but that isn’t working either.
So that is why I thought perhaps the setUIProperty could help me
application.setUIProperty('Button.background', new java.awt.Color(0xff00ff))
application.setUIProperty('Button.foreground', new java.awt.Color(0x70ff30))
I expected that the following would work also, but that is not the case:
application.setUIProperty('Button.background', new java.awt.Color(255, 0, 255))
application.setUIProperty('Button.foreground', new java.awt.Color(112, 255, 48))
This is what happens if you start to use Java in Servoy . From what I see in java.awt.Color there is (among other constructors) this:
Color(float r, float g, float b)
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0.0 - 1.0).
Color(int r, int g, int b)
Creates an opaque sRGB color with the specified red, green, and blue values in the range (0 - 255).
Your problem now is that your 255 arrives in Java as a Double, not an int. So you end up in the first constructor, where, of course, your figures are out of range. So you need to create a Java int first…
I’m not familiar with Java and I don’t want to neither
So the 0xff00ff solutions is good enough already.
That troubles with different types I’ve seen Jasper Reports also.
That’s why I don’t like Jasper (even when Jasper is better in positioning of fields compared to Crystal Reports)
Also full of type conversions when making some variable or checking some condition. I hate that