 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
anzenews Guest
|
Posted: Mon May 22, 2006 8:07 am Post subject: TableViewer usage |
|
|
Hi all!
I'm a bit new with SWT/JFace and I am having problems displaying table
- I would appreciate if someone could help me out.
As mentioned, I'm trying to use TableLayout to display table data:
Group group=new Group(this,SWT.SHADOW_ETCHED_IN);
group.setText("table");
group.setBounds(0,0,400,400);
final TableViewer viewer=new
TableViewer(group,SWT.BORDER|SWT.FULL_SELECTION);
TableLayout layout=new TableLayout();
layout.addColumnData(new ColumnWeightData(33,true));
layout.addColumnData(new ColumnWeightData(33,true));
layout.addColumnData(new ColumnWeightData(33,true));
viewer.getTable().setLayout(layout);
viewer.getTable().setLinesVisible(true);
viewer.getTable().setHeaderVisible(true);
// Set up the table layout
TableColumn column1 = new TableColumn(viewer.getTable(), SWT.CENTER);
TableColumn column2 = new TableColumn(viewer.getTable(), SWT.CENTER);
TableColumn column3 = new TableColumn(viewer.getTable(), SWT.CENTER);
TableItem item = new TableItem(viewer.getTable(), SWT.NONE);
item.setText( new String[] { "column 1",
"column 2",
"column 3" } );
item = new TableItem(viewer.getTable(), SWT.NONE);
item.setText( new String[] { "a", "b", "c" } );
Now the Group gets displayed, but the table inside it doesn't, all I
see is an empty space. I think I'm missing out something very basic -
could you please help me out?
Thank you in advance & happy coding!
Anze |
|
| Back to top |
|
 |
anzenews Guest
|
Posted: Mon May 22, 2006 10:07 am Post subject: Re: TableViewer usage |
|
|
Anyone? Please?
I just want to display a table using JFace... I have a component that
is displayed (Group) and I want a table inside it.
I would be grateful for any hints, I am out of ideas. :(
Anze |
|
| Back to top |
|
 |
anzenews Guest
|
Posted: Mon May 22, 2006 11:07 am Post subject: Re: TableViewer usage |
|
|
Actually, no - what made the difference was a few lines just before
creating the TableViewer:
GridLayout gl=new GridLayout(4,false);
group.setLayout(gl);
Anze |
|
| Back to top |
|
 |
anzenews Guest
|
Posted: Mon May 22, 2006 11:07 am Post subject: Re: TableViewer usage |
|
|
Grrrrr... :(
This helped:
group.pack();
(added at the end of the posted code)
Anze |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|