Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-08-2009, 05:35 AM
Member
 
Join Date: Feb 2009
Posts: 1
Rep Power: 0
feiqu0325 is on a distinguished road
Default Can't add columns in table viewer
Hi, I want to create a table viewer with some columns. I created a table viewer by swt designer. Then I added columns and column names by code. However, I couldn't find those columns in design mode and run time. Following is my source (including code generated by swt designer). Please help me to fix this problem. Thanks!
final TableViewer tableViewer = new TableViewer(shell, SWT.BORDER);
final Table table = tableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setBounds(32, 28, 400, 100);
TableLayout layout = new TableLayout();
table.setLayout(layout);
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Flight ID");
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Airplane ID");
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Seat number");
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Airplane type");
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Departure date");
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Departure location");
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Destination");
layout.addColumnData(new ColumnWeightData(50));
new TableColumn(table, SWT.NONE).setText("Cost");
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 03-24-2009, 01:46 PM
Member
 
Join Date: Mar 2009
Posts: 42
Rep Power: 0
trax is on a distinguished road
Default
final TableViewer tableViewer = new TableViewer(shell, SWT.BORDER);
final Table table = tableViewer.getTable();

TableLayout layout = new TableLayout();
table.setLayout(layout);



TableColumn column = new TableColumn(table, SWT.NONE);
column.setWidth(200);
column.setText("Flight Id");

column = new TableColumn(table, SWT.NONE);
column.setWidth(200);
column.setText("Airplane Id");

column = new TableColumn(table, SWT.NONE);
column.setWidth(200);
column.setText("Airplane Type");



table.setLinesVisible(true);
table.setHeaderVisible(true);
table.setBounds(32, 28, 400, 100);


Use this code n it will show columns.
Regards,
vinay
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Jface Viewer help JohnTayler SWT / JFace 2 04-23-2009 12:28 AM
How to resize columns as SWT table resizes Java Tip SWT 0 07-11-2008 04:08 PM
Annotation Viewer Java Tip java.lang 0 04-17-2008 12:01 AM
Getting names of table columns Java Tip Java Tips 0 01-07-2008 09:39 AM
iSQL-Viewer 3.0.0 levent Java Announcements 0 06-04-2007 09:06 AM


All times are GMT +2. The time now is 04:40 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org