Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table row background(Opaque controls)
Table row background [message #517822] Tue, 02 March 2010 09:35 Go to next message
Jason Davis is currently offline Jason DavisFriend
Messages: 3
Registered: March 2010
Junior Member
Hello,
I have a table. Odd rows are one color even another. The table has 3 columns.
I use a Label,button(push),button(check) as the editors for the respective columns.
After some reading it seems label or text can not inherit the background color or be transparent, the parts thats not text that is. Is there some other way to do this? Or have I been misinformed? In short I'm hoping for somthing like JLabel with setOpaque(false)

Thank You,
Jason

	private void initPluginList(Shell shell)
	{
		Composite comp = new Composite(shell, SWT.NO_FOCUS);
		comp.setLayout(Bag.layout());
		comp.setLayoutData(new Bag().fillBoth().get());
		
		Table table = new Table (comp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
		table.setLayoutData(new Bag().fillBoth().get());
		table.setLinesVisible (true);
		table.setBackgroundMode(SWT.INHERIT_FORCE);
		
		Plugin plugin = new Plugin();
		plugin.name = "FooPlugin";
		plugin.enabled = true;
		
		TableColumn[] columns = new TableColumn[3];
		for (int i=0; i<3; i++) columns[i] = new TableColumn(table, SWT.NONE);
		
		columns[0].setWidth(300);
		columns[1].setWidth(50);
		columns[2].setWidth(100);
		
		Label label = new Label(table, SWT.NONE);
		label.setText(plugin.name);
		
		Button args = new Button(table, SWT.PUSH);
		args.setText("Args");
		
		Button enabled = new Button(table, SWT.CHECK);
		enabled.setText("Enable");
		
		TableItem ti = new TableItem(table, SWT.NONE);
		TableEditor te = new TableEditor(table);
		te.grabHorizontal = true;
		te.horizontalAlignment = SWT.FILL;
		te.setEditor(label, ti, 0);
		
		te = new TableEditor(table);
		te.minimumWidth = 50;
		te.setEditor(args, ti, 1);
		
		te = new TableEditor(table);
		te.minimumWidth = 100;
		te.setEditor(enabled, ti, 2);
	}

[Updated on: Tue, 02 March 2010 09:37]

Report message to a moderator

Re: Table row background [message #517938 is a reply to message #517822] Tue, 02 March 2010 15:07 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Jason,

Showing these controls transparently isn't possible, but you should be able
to get close to what you want with a couple of changes:
- Is there a reason that you're embedding Label controls in the first
column? I can't think of advantages that these would give over simply
setting the TableItem's image and text. If you switched to do this then you
would get the correct background.
- There isn't a way to make the push button transparent, which is platform
behaviour.
- For the last column you could give the check Button no text and pack it,
and use custom draw to draw the item text at the correct location to the
right of the checkbox. The only part that would not be transparent would be
the checkbox itself. For info about custom drawing of Table/Tree items see
http://www.eclipse.org/articles/article.php?file=Article-Cus tomDrawingTableAndTreeItems/index.html .

Hopefully these changes can get you reasonably close to what want (?).

Grant


"Jason Davis" <jdavis@openactive.org> wrote in message
news:hmim58$41f$1@build.eclipse.org...
> Hello,
> I have a table. Odd rows are one color even another. The table has 3
columns.
> I use a Label,button(push),button(check) as the editors for the respective
columns.
> After some reading it seems label or text can not inherit the background
color or be transparent, the parts thats not text that is. Is there some
other way to do this? Or have I been misinformed? In short I'm hoping for
somthing like JLabel with setOpaque(true)
>
> Thank You,
> Jason
>
>
> private void initPluginList(Shell shell)
> {
> Composite comp = new Composite(shell, SWT.NO_FOCUS);
> comp.setLayout(Bag.layout());
> comp.setLayoutData(new Bag().fillBoth().get());
>
> Table table = new Table (comp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
> table.setLayoutData(new Bag().fillBoth().get());
> table.setLinesVisible (true);
> table.setBackgroundMode(SWT.INHERIT_FORCE);
>
> Plugin plugin = new Plugin();
> plugin.name = "FooPlugin";
> plugin.enabled = true;
>
> TableColumn[] columns = new TableColumn[3];
> for (int i=0; i<3; i++) columns[i] = new TableColumn(table, SWT.NONE);
>
> columns[0].setWidth(300);
> columns[1].setWidth(50);
> columns[2].setWidth(100);
>
> Label label = new Label(table, SWT.NONE);
> label.setText(plugin.name);
>
> Button args = new Button(table, SWT.PUSH);
> args.setText("Args");
>
> Button enabled = new Button(table, SWT.CHECK);
> enabled.setText("Enable");
>
> TableItem ti = new TableItem(table, SWT.NONE);
> TableEditor te = new TableEditor(table);
> te.grabHorizontal = true;
> te.horizontalAlignment = SWT.FILL;
> te.setEditor(label, ti, 0);
>
> te = new TableEditor(table);
> te.minimumWidth = 50;
> te.setEditor(args, ti, 1);
>
> te = new TableEditor(table);
> te.minimumWidth = 100;
> te.setEditor(enabled, ti, 2);
> }
>
Re: Table row background [message #518026 is a reply to message #517938] Tue, 02 March 2010 19:42 Go to previous message
Jason Davis is currently offline Jason DavisFriend
Messages: 3
Registered: March 2010
Junior Member
Thank you Grant. Got it working the way I wanted with your suggestions. Thanks.

http://openactive.org/pastebin/images/paste/3XP693NK.jpg
Previous Topic:SWT handle difference between platform
Next Topic:ExpandBar - Table - scroll
Goto Forum:
  


Current Time: Fri Apr 19 06:56:24 GMT 2024

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

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

Back to the top