Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Colors in SWT

Tags:

java

colors

swt

This is pretty simple, I come from a swing/awt background.

I'm just wondering what the proper way to set the background color for a SWT widget is?

I've been trying:

widget.setBackground( );

Except I have no idea how to create the color Object in SWT?

like image 888
Brian Gianforcaro Avatar asked Sep 08 '08 16:09

Brian Gianforcaro


2 Answers

Remember that in SWT you must explicitly dispose any resources that you create when you are done with them. This includes widgets, fonts, colors, images, displays, printers, and GCs. If you do not dispose these resources, eventually your application will reach the resource limit of your operating system and the application will cease to run.

See also: SWT: Managing Operating System Resources

like image 196
qualidafial Avatar answered Nov 06 '22 05:11

qualidafial


To create a color, try this:

Device device = Display.getCurrent ();
Color red = new Color (device, 255, 0, 0);
like image 37
jodonnell Avatar answered Nov 06 '22 06:11

jodonnell