Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Setting specific background and border colors to buttons(Adding specific colors to buttons)
Setting specific background and border colors to buttons [message #1007718] Thu, 07 February 2013 04:58 Go to next message
K C is currently offline K C
Messages: 2
Registered: February 2013
Junior Member
We use RAP 1.2 as our GUI based engine. I have been asked to set the colors of the background (to #8FA8BF) and border(to #7B92AB) and also the text (to #FFFFFF).

I tried the following code in a sub-class of org.eclipse.swt.widgets.Button:

public class Button extends org.eclipse.swt.widgets.Button {
public Button(Composite parent, int style) {
super(parent, style);
this.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
Color buttonColor = new Color(e.display, 143, 168, 91);
e.gc.setBackground(buttonColor);

buttonColor.dispose();
}
});
}
}

Is this the right approach? In my Eclipse, when I attach the 3.5 SWT jars, then it compiles. But, when I try to compile it using our build (Ant based), which uses the RAP 1.2 plugins, then it fails to recognize PaintListener, PaintEvent and also the addPaintListener method. What am I doing wrong?
Re: Setting specific background and border colors to buttons [message #1015722 is a reply to message #1007718] Fri, 01 March 2013 16:43 Go to previous message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
Hi,

In plain SWT you set a Control's background with the setBackground()
API. However note that this is considered a hint that the native
platform can choose to respect or not. Button backgrounds on win32
cannot be changed this way, but on GTK they can. If you are bound by
native constraints like this then you will not be able to change your
Button's background (on win32).

I'm not sure what the connection to RAP is, but if this does not answer
your question then you should re-post it on a RAP-specific newsgroup/forum.

Grant


On 2/7/2013 7:25 AM, K C wrote:
> We use RAP 1.2 as our GUI based engine. I have been asked to set the
> colors of the background (to #8FA8BF) and border(to #7B92AB) and also
> the text (to #FFFFFF).
> I tried the following code in a sub-class of
> org.eclipse.swt.widgets.Button:
>
> public class Button extends org.eclipse.swt.widgets.Button {
> public Button(Composite parent, int style) {
> super(parent, style);
> this.addPaintListener(new PaintListener() {
> public void paintControl(PaintEvent e) {
> Color buttonColor = new Color(e.display, 143, 168, 91);
> e.gc.setBackground(buttonColor);
>
> buttonColor.dispose();
> }
> });
> }
> }
>
> Is this the right approach? In my Eclipse, when I attach the 3.5 SWT
> jars, then it compiles. But, when I try to compile it using our build
> (Ant based), which uses the RAP 1.2 plugins, then it fails to recognize
> PaintListener, PaintEvent and also the addPaintListener method. What am
> I doing wrong?
Previous Topic:Focus Issue
Next Topic:Transparent Shell
Goto Forum:
  


Current Time: Fri Jul 25 21:10:36 EDT 2014

Powered by FUDForum. Page generated in 0.02789 seconds