Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to show horizontal scrollbar in table without using TableColumn.pack()
How to show horizontal scrollbar in table without using TableColumn.pack() [message #480933] Wed, 19 August 2009 01:41 Go to next message
Praveen K Subramanian is currently offline Praveen K SubramanianFriend
Messages: 11
Registered: July 2009
Junior Member
Hi all,

I have a table with two columns(as in the code below). The value in the
second column is long and adding column2.pack() makes the dialog look big.
But if I set column2.width(specific number) instead of column2.pack(),
then the horizontal scrollbar won't be visible for that column.

Is there a workaround?

Code snippet:

final Table table = new Table(shell, SWT.BORDER | SWT.RESIZE |
SWT.H_SCROLL | SWT.V_SCROLL);
table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

final TableColumn column1 = new TableColumn(table, SWT.LEFT);
column1.setText("Column 1");

final TableColumn column2 = new TableColumn(table, SWT.LEFT);
column2.setText("Column 2");

table.setHeaderVisible(true);
table.setLinesVisible(true);

final TableItem item = new TableItem(table, SWT.NULL);
item.setText(0, "abcdefgh");
item.setText(1, "123456789012345678901234567890");

column1.pack();
column2.pack();
Re: How to show horizontal scrollbar in table without using TableColumn.pack() [message #481789 is a reply to message #480933] Mon, 24 August 2009 10:43 Go to previous messageGo to next message
Praveen Missing name is currently offline Praveen Missing nameFriend
Messages: 6
Registered: July 2009
Junior Member
Instead of calling shell.pack(), if shell.setSize() is used, then the
dialog will appear as the preferred size and at the same time, scrollbar
would appear on Table as well.
So, the main idea is that - the table has to be contained in a
Scrolled-Composite and set it's preferred size. Thus, table will be
displayed smaller than it's original size and scrollbar will appear.
Re: How to show horizontal scrollbar in table without using TableColumn.pack() [message #482547 is a reply to message #481789] Thu, 27 August 2009 01:27 Go to previous message
Praveen K Subramanian is currently offline Praveen K SubramanianFriend
Messages: 11
Registered: July 2009
Junior Member
Thank you Praveen.
Previous Topic:Auto-sized TreeViewer columns
Next Topic:FilteredLists and accessibility
Goto Forum:
  


Current Time: Fri Aug 23 08:45:27 GMT 2019

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

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

Back to the top