【发布时间】:2015-01-20 12:50:16
【问题描述】:
我想在 Eclipse 中创建一个页面,该页面有两个相邻的树组件和一个位于树下的表格。
我编写的代码可以做到这一点,但我还希望表格和树可以调整大小。当我调整大小使表格变小时,树应该变大。
我尝试了一些在互联网上找到的不同方法,但都没有奏效。
这是我写的代码:
@PostConstruct
public void postConstruct(Composite parent, MApplication app) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL,SWT.FILL, true, true, 1,1));
composite.setLayout(new GridLayout(2, true));
treeLeft = new TreeViewer(composite);
treeLeft.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
treeRight = new TreeViewer(composite);
treeRight.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
Composite tableComposite = new Composite(parent, SWT.NONE);
tableComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
tableComposite.setLayout(new GridLayout());
table = new TableViewer(tableComposite, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
GridData grid = new GridData(GridData.FILL_BOTH);
grid.horizontalSpan = 4;
table.setContentProvider(ArrayContentProvider.getInstance());
createTableColumns();
table.getControl().setLayoutData(grid);
table.getTable().setHeaderVisible(true);
table.getTable().setLinesVisible(true);
【问题讨论】:
-
你看过
SashForms吗?