Skip to main content



      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 00:41 Go to next message
Eclipse UserFriend
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 09:52] by Moderator

Re: SWT windowbuilder color not show on label etc only composite [message #1386866 is a reply to message #1386644] Sat, 21 June 2014 22:24 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 23 June 2014 23:44 Go to previous messageGo to next message
Eclipse UserFriend
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 04:40 Go to previous messageGo to next message
Eclipse UserFriend
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] Wed, 25 June 2014 21:22 Go to previous messageGo to next message
Eclipse UserFriend
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] Wed, 25 June 2014 21:28 Go to previous messageGo to next message
Eclipse UserFriend
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 03:23 Go to previous message
Eclipse UserFriend
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: Mon Jul 14 06:03:23 EDT 2025

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

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

Back to the top