| Author |
Message |
|
|
Post subject: setBackground color of Button
Posted: Jun 30, 2005 - 04:37 AM
|
|
|
|
Hi,
I try to change the background of button (type push) using the following code:
Button button = new Button(this, SWT.NONE);
setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW));
But the color of button does not change.
Does any body know what is going wrong in this code? |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: setBackground color of Button
Posted: Jul 01, 2005 - 09:07 AM
|
|
|
|
| Nothing is wrong with the code. Windows simply does not allow you to change the background color of buttons, so that code is ignored. |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: setBackground color of Button
Posted: Jul 01, 2005 - 09:52 AM
|
|
|
|
Hi !
It is a long time I have not coded in java but i think you have to set the Opaque Properties to true ???
Sergio |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: setBackground color of Button
Posted: Aug 11, 2005 - 02:20 AM
|
|
|
|
Hi shouldn't your code read:
button.setBackground()
instead of just setBackground()? |
|
|
| |
|
|
|
 |
|
|
Post subject: Re: setBackground color of Button
Posted: May 03, 2006 - 02:05 PM
|
|
|
|
Hello I changed the color or my buttons and background with this code
In my case they are part of a group.
Group group2 = new Group(shell, SWT.RADIO);
group2.setBackground(new Color(null,0xEE,0xEE,0xEE));
buttonradio2 = new Button(group2, SWT.RADIO);
buttonradio2.setText("TestButton");
buttonradio2.setBackground(new Color(null,0xEE,0xEE,0xEE));
I hope it will help
Chau! , Maria Silvana S.
| staaouat wrote: | Hi,
I try to change the background of button (type push) using the following code:
Button button = new Button(this, SWT.NONE);
setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_YELLOW));
But the color of button does not change.
Does any body know what is going wrong in this code? |
|
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jan 29, 2007 - 01:26 AM
|
|
Joined: Jan 29, 2007
Posts: 1
|
|
Hi All,
I too have a similar requirement. But i want to replace a button with an image..
Below is the code.. Am getting the image.. But with default background color. I need to edit that color or without any background with jst image... Can anyone help me out in this please..
Thanks in advance
| Code: |
final Image imageClose=new Image(display,"Image/Cancel Search.png");
Button b1=new Button(shell,SWT.PUSH);
b1.setImage(imageClose);
b1.setBackground(new Color(null,41,0,23));
b1.setLocation(265,2);
|
|
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Dec 21, 2007 - 09:56 AM
|
|
Joined: Dec 21, 2007
Posts: 1
|
|
| Quote: | | Nothing is wrong with the code. Windows simply does not allow you to change the background color of buttons, so that code is ignored. |
It is not every time true. The classic windows theme style is not compatible with java applications setting background color for buttons. Switch to WinXP style, and surprise-surprise... it works. |
|
|
| |
|
|
|
 |
|
|