Appearance of disabled elements

Hi

We disable forms elements like buttons with the statement: elements.btnInsert.enabled = false;

Visually this appears like the first screenshot – hard to see what element it is when it’s not grayed out, and visually not very appealing

I would prefer to have the visual appearance something like the second screenshot, clearly to read and visually appealing

Is this currently possible with Servoy 5.2.7, i. e. is there another command leading to the desired result?

Regards,

maybe you can tweak the ui defaults, here is a list:

http://www.duncanjauncey.com/java/ui/ui … _OS_X.html

see also servoy camp: http://www.servoycamp.com/topics/tips/1 … -feel.html

Do you know the file location of the look and feel file to be tweaked?

jcompagner:
maybe you can tweak the ui defaults, here is a list:

http://www.duncanjauncey.com/java/ui/ui … _OS_X.html

see also servoy camp: http://www.servoycamp.com/topics/tips/1 … -feel.html

Robert, what Johan, means is, that you can override, certain L&F behaviour right from Servoy.

Did you read the article??

We for instance, don’t like the comboboxes when they, are disabled, so we override this on our onSolutionOpen method

	application.setUIProperty("ComboBox.disabledBackground", new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.WHITE));
	application.setUIProperty("ComboBox.disabledForeground", new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.BLACK));

So in your case, you have to search in that list, Johan, gave you, for something that set’s the disabledForeground, for a label or button

I see: Button.disabledText
or
Label.disabledForeground

so play with that a little bit, and see what works…

Ah, thanks now I undestand!

I tried to set an RGB value instead of … java.awt.Color.BLACK, something like
application.setUIProperty(“Button.foreground”, new Packages.javax.swing.plaf.ColorUIResource.getColor([r = 40, g = 30, b = 0]));

I tried various forms of the syntax, but none was correct.

Any idea?

Regards,

new Packages.javax.swing.plaf.ColorUIResource(10,20,30)

something like that could work
Problem is that that constructor has integers and floats. So it could be that you have to do

new Packages.javax.swing.plaf.ColorUIResource(0.1,0.2,0.3);

where the 0.1 is used as 0.1*255=25 so R =25

Thanks Johan

The solution is your 2nd attempt for all others interested in this. So, for example the following makes the button font color a certain orange:

application.setUIProperty(“Button.foreground”, new Packages.javax.swing.plaf.ColorUIResource(0.969,0.286,0.008)); // Button font color r:247, b:73, g:2 (0.969 * 255, 0.286 * 255, 0.008 * 255)

This is for demo purposes, not that I am saying this color is a good idea - it’s not .-)

Regards,

jcompagner:
new Packages.javax.swing.plaf.ColorUIResource(10,20,30)

something like that could work
Problem is that that constructor has integers and floats. So it could be that you have to do

new Packages.javax.swing.plaf.ColorUIResource(0.1,0.2,0.3);

where the 0.1 is used as 0.1*255=25 so R =25

Keep it simple! var vBackgroundcolor = new Packages.javax.swing.plaf.ColorUIResource(Packages.java.awt.Color.decode(‘#8492a5’))

:-)

I try hard to keep it simple :-) but doesn’t always work in the first attempt ;-)

I still didn’t find a way to change the color (by default L&F dark grey) of a disabled button having an image media (attached). If you have an idea, I would be very pleased :-)

Regards,

Harjo:
Keep it simple! var vBackgroundcolor = new Packages.javax.swing.plaf.ColorUIResource(Packages.java.awt.Color.decode(‘#8492a5’))

:-)

oke, is it a button? or a label??

have you tried setting:

Label.background	CColorPaintUIResource	Color[238,238,238]	#EEEEEE
Label.disabledForeground	ColorUIResource	Color[128,128,128]	#808080
Label.disabledShadow	ColorUIResource	Color[64,64,64]	#404040
Label.font	DerivedUIResourceFont	Font[family=Lucida Grande,name=Lucida Grande,style=0,size=13]	 
Label.foreground	ColorUIResource	Color[0,0,0]

Harjo:
oke, is it a button? or a label??

It’s a button.

Harjo:
have you tried setting:

Label.background	CColorPaintUIResource	Color[238,238,238]	#EEEEEE

Label.disabledForeground ColorUIResource Color[128,128,128] #808080
Label.disabledShadow ColorUIResource Color[64,64,64] #404040
Label.font DerivedUIResourceFont Font[family=Lucida Grande,name=Lucida Grande,style=0,size=13]
Label.foreground ColorUIResource Color[0,0,0]

For example, the following command is setting the font color of buttons like the ones in the login dialog, but does NOT set the font color of Servoy buttons

application.setUIProperty('Button.foreground', new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.decode('#004fcb'))); // Button font color

On the other hand, this command sets the background of a Servoy button (without an imageMedia attached)

application.setUIProperty('Button.background', new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.decode('#e0a467'))); // Button background color

But if I have a button with a imageMedia, and it’s disabled with

elements.btnInsert.enabled = false;

then the button gets a dark grey. How can I change the color of THIS button, i. e. the color of the imageMedia, I assume?
The above commands don’t work on Servoy buttons when a imageMedia is attached!
Any idea how to control buttons with imageMedia attached?

Regards