小编oli*_*leo的帖子

使控件可调整大小

我想在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);
Run Code Online (Sandbox Code Playgroud)

java swt composite

1
推荐指数
1
解决办法
700
查看次数

标签 统计

composite ×1

java ×1

swt ×1