Search code examples
javauser-interfaceswtjfacetableviewer

Make a JFace TableViewer resize with it's surrounding composite?


Using the WindowBuilder for Eclipse, I have created a TableViewer which I have placed inside a composite. (The TableViewer creates an SWT Table, in which the TableViewer itself is inserted).

I have tried to make the composite resizable by setting grabExcessHorizontalSpace and grabVerticalSpace to true, but how to I make also the table and the TableViewer fill the composite?


Solution

  • Hard to tell without code, but from your description you don't set a layout on your Composite. Try adding composite.setLayout(new FillLayout()); if your composite contains only the TableViewer.

    If your composite has more than one child, you'll need a different layout, like GridLayout, or MigLayout. Then you'll also have to set layoutData on your Table and the other children of your composite.

    Here are some snippets, which show how to use GridLayout. To learn MigLayout, which I find way better, see here.