change button color from grey to white

Hi all,

OS: Windows XP Pro
Servoy version: 4.1 for smart client based application

When we create buttons the default fill color is grey. I would like to change it to white. What would be the best way to do it.

I ran a test to change using setUIProperty but that did not change the grey fill area.
application.setUIProperty(“Button.background”, new Packages.javax.swing.plaf.ColorUIResource(java.awt.Color.white));

I used another approach of attaching a style class by modifying the css but that did not work either.
button.newStyle
{
background-color:00BFFF;
}

I tested application.overrideStyle(‘oldStyle’,‘newStyle’) to see if that would help.

Is there another way of getting it done or do I need to set/unset some properties in the button to get it to work.

In normal html we can create and input button type and then set a css style to the button and the background-color would change the grey color to any particular color we like. But I am not able to get the same result when I am setting the properties for the button.

Any help on this would be appreciated.

Regards
James

The fill color of a button is determined by the Look&Feel, you can either write your own look&feel or just disable the showClick property of the button and it will behave like any label object (and then you can use CSS to customize it).

Use this stylesheet:

button {
	background-color: #00bfff;
}

and make sure that the styleName of the forms is set to the right style, the styleClass of the buttons should just be “DEFAULT”.

Hi,

Thanks for the replies.

I am using the servoy_sample_crm to test it. I added the following code to the svyWebCrm.css

    button {
       background-color: #00bfff;
    }

I set the form properties of frm_company layout as follows form.styleName = svyWebCrm and form.styleClass = DEFAULT

I have attached pic1.jpg to show the properties set for the cancel button

I have also attached pic2.jpg to show the how it behaves on the smart client. It still shows the grey fill with the light blue at the background.

As I have to enable the cancel button’s showClick property in order to show the click effect.

Is writing a custom Look&Feel just to set the button grey fill to white fill the only option. If yes any pointers on what resources are available out there for me to create a custom Look&Feel.

Any help would be appreciated.

Regards
jdcunha

Writing a Look&Feel only for this is an overkill IMO, why don’t you just disable the “showClick” property of the buttons? Then you can apply any CSS or use images as buttons, you only lose that 3d feeling of the default buttons.

As its a kiosk based application It needs to have the button 3d feel. We initially had it that way but we had to revert it back to buttons in order to get that feel.

jdcunha:
I am using the servoy_sample_crm to test it. I added the following code to the svyWebCrm.css

    button {
   background-color: #00bfff;
}



I set the form properties of frm_company layout as follows form.styleName = svyWebCrm and form.styleClass = DEFAULT

I don’t really understand what your problem is. If I do the exact steps you mention here, my buttons are colored, see screenshot:

Hi Joas,

So it works. Would it be possible for you to send me the exported sample solution. I would like to import it and see what exactly the problem is on my end.

Thanks a lot.

Regards
jdcunha

It is probably something stupid like a missing “;” in the stylesheet.

Here it is the export:

It just doesn’t work for me as well, if you find the reason, please update this topic.

Tnx

guys, Joas, is using Windows classic!!
THAN coloring the button works, not if you use the standard L&F of XP.

Yes you are right when I changed my L&F to classic it changed but not when set to default.

So with the client set to default L&F on Windows, I will not be able to change the button fill to white unless I change it to a custom L&F.

Jdcunha

Ah-ah!
It’s not fair to use Windows Classic L&F… :)

I guess it’s a ‘classic’ mistake ;)

jdcunha:
Yes you are right when I changed my L&F to classic it changed but not when set to default.

So with the client set to default L&F on Windows, I will not be able to change the button fill to white unless I change it to a custom L&F.

Jdcunha

And the ‘classic’ answer is: you are right! ;-)

Aren’t we a classy bunch. ;)

Thanks for all the ‘classic’ replies. Appreciate everyone’s help on this. 8)

jdcunha

Harjo:
guys, Joas, is using Windows classic!!
THAN coloring the button works, not if you use the standard L&F of XP.

In fact I’m using the default L&F, but in Vista instead of XP. So this issue seems to be XP-only. :?

Hi Joas,

Will we have this issue addressed in 3.5.x/4.1.x future release ?

jdcunha

Joas,

default in Servoy takes over the default L&F of Vista & XP !!
and you have set Vista to Classic!

that’s why it works for you.