Auto-sizing Table Columns

Tell us what you think about our book and report any errata. Sample chapters are available at

(Note: Previous Editions were called "Eclipse: Building Commercial Quality Plugins")

Moderators: Eric Clayberg, Dan Rubel

Auto-sizing Table Columns

Postby jnorris » Mon Aug 02, 2004 11:45 am

Posts: 17
Joined: Tue Jul 27, 2004 5:10 am

Re: Auto-sizing Table Columns

Postby Eric Clayberg » Mon Aug 02, 2004 7:26 pm

The first code snippet on p342 should read "table.setLayout(new AutoResizeTableLayout(table));" (note the additional constructor argument).

The following additional explanatory text should be included:

For each column, you will need to supply additional layout information. For Example:

    // fixed width column
    layout.addColumnData(new ColumnPixelData(18));

    // weighted column
    layout.addColumnData(new ColumnWeightData(50));
The FavoritesView can use the AutoResizeTableLayout class by modifying the code shown in Section 7.2.2, "View controls," after which the columns in the view will automatically be resized when the view is resized.

    viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
    final Table table = viewer.getTable();

    TableColumn typeColumn = new TableColumn(table, SWT.LEFT);
    layout.addColumnData(new ColumnPixelData(18));

    TableColumn nameColumn = new TableColumn(table, SWT.LEFT);
    layout.addColumnData(new ColumnWeightData(200));

    TableColumn locationColumn = new TableColumn(table, SWT.LEFT);
    layout.addColumnData(new ColumnWeightData(200));

Eric Clayberg
Software Engineering Manager

Author: "Eclipse Plug-ins"
Eric Clayberg
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Postby jnorris » Tue Aug 03, 2004 4:01 am

Thanks for the reply Eric,

I'll give it a try later today.

Posts: 17
Joined: Tue Jul 27, 2004 5:10 am

Return to Book: Eclipse Plug-Ins (3rd Edition)

Who is online

Users browsing this forum: No registered users and 1 guest