Plugins (1057)


Training and Consulting (44)



EPIC Poll

What is your favourite developer portal?

[ Results | Polls ]

Votes: 541
Comments: 0

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
staaouat
Post subject: setBackground color of Button  PostPosted: Jun 30, 2005 - 04:37 AM
Guest





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?
 
   
Reply with quote Back to top
Guest
Post subject: RE: setBackground color of Button  PostPosted: 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.
 
   
Reply with quote Back to top
Guest
Post subject: RE: setBackground color of Button  PostPosted: 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
 
   
Reply with quote Back to top
Guest
Post subject: RE: setBackground color of Button  PostPosted: Aug 11, 2005 - 02:20 AM






Hi shouldn't your code read:

button.setBackground()

instead of just setBackground()?
 
   
Reply with quote Back to top
Guest
Post subject: Re: setBackground color of Button  PostPosted: 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. Smile






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?
 
   
Reply with quote Back to top
shruthi04
Post subject:   PostPosted: 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);
 
 View user's profile Send private message  
Reply with quote Back to top
jamesgt
Post subject:   PostPosted: 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.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits