Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] GridLayout (w/Table) and vertical alignment problems


I'm trying to create a screen using a GridLayout with two columns.  On the left column I want three vertical buttons and on the right column I want a Table.  My problem is that I cannot get the buttons to align with the top of the Table.  They always align with the center of the table no matter what I try.  Below is my code and I have attached a screenshot of the screen.  Thanks for the help.

---------------------------------------
public Control createContents(Composite parent)
{
        Composite composite = new Composite(parent, SWT.NONE);

        GridLayout layout = new GridLayout();

        layout.numColumns = 2;
        composite.setLayout(layout);

        Composite buttons = new Composite(composite, SWT.NONE);
        GridLayout buttonLayout = new GridLayout();
        buttonLayout.numColumns = 1;
        buttons.setLayout(buttonLayout);

        Button button = new Button(buttons, SWT.PUSH);
        button.setText("Add Model");
        GridData data = "" GridData();
        data.widthHint = 100;
        button.setLayoutData(data);

        button = new Button(buttons, SWT.PUSH);
        button.setText("Work with Model");
        data = "" GridData();
        data.widthHint = 100;
        button.setLayoutData(data);
       
        button = new Button(buttons, SWT.PUSH);
        button.setText("Export to Score");
        data = "" GridData();
        data.widthHint = 100;
        button.setLayoutData(data);

        final TableViewer tbv =        new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
        tbv.setContentProvider(new TableCP());
        tbv.setLabelProvider(new TableLP(composite.getDisplay()));

        GridData gridData = new GridData();
        gridData.horizontalAlignment = GridData.FILL;
        gridData.grabExcessHorizontalSpace = true;
        gridData.grabExcessVerticalSpace = true;
        gridData.verticalAlignment = GridData.FILL;
        tbv.getTable().setLayoutData(gridData);

        TableColumn column = new TableColumn(tbv.getTable(), SWT.LEFT);
        column.setText("ID");
        column.setWidth(50);

        column = new TableColumn(tbv.getTable(), SWT.LEFT);
        column.setText("Description");
        column.setWidth(300);

        column = new TableColumn(tbv.getTable(), SWT.LEFT);
        column.setText("Status");
        column.setWidth(100);

        tbv.getTable().setHeaderVisible(true);

        return composite;
}
------------------------------------------------------------

Robert Johnson
Oreilly Automotive, Inc.
Information Systems - Internet Team
417-862-2674 x1878

Attachment: screenshot.jpg
Description: JPEG image


Back to the top