AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TableViewer usage

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
anzenews
Guest





PostPosted: Mon May 22, 2006 8:07 am    Post subject: TableViewer usage Reply with quote



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





PostPosted: Mon May 22, 2006 10:07 am    Post subject: Re: TableViewer usage Reply with quote



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





PostPosted: Mon May 22, 2006 11:07 am    Post subject: Re: TableViewer usage Reply with quote



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





PostPosted: Mon May 22, 2006 11:07 am    Post subject: Re: TableViewer usage Reply with quote

Grrrrr... :(


This helped:
group.pack();

(added at the end of the posted code)

Anze
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.