Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » SWT windowbuilder color not show on label etc only composite
SWT windowbuilder color not show on label etc only composite [message #1386644] Thu, 19 June 2014 04:41 Go to next message
charlie schindler is currently offline charlie schindlerFriend
Messages: 28
Registered: June 2014
Junior Member
I created a SWT Dialog put 2 tabs inside and composites within the tab
now added a Label and a Combo and wanted to color them, neither fore- nor backend color show up.
Using a Jpanel and then using comboBox the coloring works.
I tried many different things none made the color appear...

Here the code for SWT controls complete code in attached file

CTabItem tabItem_3 = new CTabItem(patientDataTab, SWT.NONE);
tabItem_3.setImage(SWTResourceManager.getImage(patientForm.class,
				"/com/sun/java/swing/plaf/windows/icons/NewFolder.gif"));
tabItem_3.setText("New Item");
composite_1 = new Composite(patientDataTab, SWT.NONE);
composite_1.setForeground(SWTResourceManager.getColor(SWT.COLOR_YELLOW));
composite_1.setBackgroundMode(SWT.INHERIT_FORCE);
composite_1.setBackground(SWTResourceManager.getColor(0, 206, 209));
tabItem_3.setControl(composite_1);
formToolkit.paintBordersFor(composite_1);
composite_1.setLayout(new GridLayout(10, false));

Label genderLabel = new Label(composite_1, SWT.NONE);
genderLabel.setBackgroundImage(null);
		genderLabel.setBackground(SWTResourceManager.getColor(SWT.COLOR_CYAN));
genderLabel.setAlignment(SWT.RIGHT);
genderLabel.setDragDetect(false);
		genderLabel.setForeground(SWTResourceManager.getColor(SWT.COLOR_BLUE));
genderLabel.setBounds(0, 0, 55, 15);
formToolkit.adapt(genderLabel, true, true);
genderLabel.setText(Messages.getString(
"patientForm.lblNewLabel.text", "Gender")); //$NON-NLS-1$ //$NON-NLS-2$

combo = new Combo(composite_1, SWT.NONE);
combo.setBackground(SWTResourceManager.getColor(245, 222, 179));
combo.setItems(new String[] { "male", "female", "unknown" });
GridData gd_combo = new GridData(SWT.FILL, SWT.CENTER, false, false, 2,
				1);
gd_combo.widthHint = 124;
combo.setLayoutData(gd_combo);
formToolkit.adapt(combo);
formToolkit.paintBordersFor(combo);
combo.setText(Messages.getString("patientForm.combo.text_1","select gender"));
new Label(composite_1, SWT.NONE);
new Label(composite_1, SWT.NONE);
new Label(composite_1, SWT.NONE);
new Label(composite_1, SWT.NONE);
new Label(composite_1, SWT.NONE);
new Label(composite_1, SWT.NONE);
new Label(composite_1, SWT.NONE);
composite_1.setTabList(new Control[] { genderLabel, combo });
m_bindingContext = initDataBindings();


Note: background color on SWT composite works...
removing the composite has no effect on colors

What is wrong?

[Updated on: Thu, 19 June 2014 13:52] by Moderator

Report message to a moderator

Re: SWT windowbuilder color not show on label etc only composite [message #1386866 is a reply to message #1386644] Sun, 22 June 2014 02:24 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
That is a side effect of using a FormToolkit. The FormToolkit controls the colors.
Re: SWT windowbuilder color not show on label etc only composite [message #1387087 is a reply to message #1386866] Tue, 24 June 2014 03:44 Go to previous messageGo to next message
charlie schindler is currently offline charlie schindlerFriend
Messages: 28
Registered: June 2014
Junior Member
thx and how can i set the FormToolkit color in the designer other than call the contructor with the colors manualy?
Re: SWT windowbuilder color not show on label etc only composite [message #1387112 is a reply to message #1387087] Tue, 24 June 2014 08:40 Go to previous messageGo to next message
charlie schindler is currently offline charlie schindlerFriend
Messages: 28
Registered: June 2014
Junior Member
charlie schindler wrote on Mon, 23 June 2014 23:44
thx and how can i set the FormToolkit color in the designer other than call the contructor with the colors manualy?


i removed the formtoolkit lines in the code and now the color shows up.
Not sure this is the right way to do it.

the formtoolkit is added automatically by the designer. so is there a way to handle it properly?
Re: SWT windowbuilder color not show on label etc only composite [message #1388076 is a reply to message #1387087] Thu, 26 June 2014 01:22 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
charlie schindler wrote on Mon, 23 June 2014 23:44
thx and how can i set the FormToolkit color in the designer other than call the contructor with the colors manualy?

Have you tried setting the background property of the formToolikt instance in designer?
Re: SWT windowbuilder color not show on label etc only composite [message #1388080 is a reply to message #1387112] Thu, 26 June 2014 01:28 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
charlie schindler wrote on Tue, 24 June 2014 04:40
the formtoolkit is added automatically by the designer

The formtoolkit is only added if you choose to use the Forms API from within designer.

The formtookit can also be deleted from within the designer, if you wish.


Re: SWT windowbuilder color not show on label etc only composite [message #1388255 is a reply to message #1388080] Thu, 26 June 2014 07:23 Go to previous message
charlie schindler is currently offline charlie schindlerFriend
Messages: 28
Registered: June 2014
Junior Member
ok, thx
Thought i tried to set the background property, but not sure. will try again
Previous Topic:WindowBuilder shows changes in design and source code but not when run as application
Next Topic:How to update GUI from Inherit Class
Goto Forum:
  


Current Time: Fri Apr 19 23:15:32 GMT 2024

Powered by FUDForum. Page generated in 0.03596 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top