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

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

<p>I've been trying:</p>

<pre><code>widget.setBackground( );
</code></pre>

<p>Except I have no idea how to create the color Object in SWT?</p>

[{'answer_id': 50128, 'author': 'jodonnell', 'author_id': 4223, 'author_profile': 'https://Stackoverflow.com/users/4223', 'pm_score': 7, 'selected': True, 'text': '<p>To create a color, try this:</p>\n\n<pre><code>Device device = Display.getCurrent ();\nColor red = new Color (device, 255, 0, 0);\n</code></pre>\n'}, {'answer_id': 75342, 'author': 'qualidafial', 'author_id': 13253, 'author_profile': 'https://Stackoverflow.com/users/13253', 'pm_score': 4, 'selected': False, 'text': '<p>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.</p>\n\n<p>See also: <a href="http://www.eclipse.org/articles/swt-design-2/swt-design-2.html" rel="noreferrer" title="Managing Operating System Resources in SWT">SWT: Managing Operating System Resources</a></p>\n'}, {'answer_id': 75509, 'author': 'qualidafial', 'author_id': 13253, 'author_profile': 'https://Stackoverflow.com/users/13253', 'pm_score': 6, 'selected': False, 'text': '<p>For standard colors (including common colors and default colors used by the operating system) Use <code>Display.getSystemColor(int)</code>, and pass in the <code>SWT.COLOR_*</code> constant for the color you want.</p>\n\n<pre><code>Display display = Display.getCurrent();\nColor blue = display.getSystemColor(SWT.COLOR_BLUE);\nColor listBackground = display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);\n</code></pre>\n\n<p>Note that you do not need to dispose these colors because SWT created them.</p>\n'}]
['https://Stackoverflow.com/questions/50064', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3415/']