Setting specific background and border colors to buttons [message #1007718] |
Thu, 07 February 2013 09:58 |
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 21:43 |
Grant Gayed Messages: 2150 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?
|
|
|
Powered by
FUDForum. Page generated in 0.02933 seconds