Tabfolder中的ScrolledComposite

时间:2013-11-12 05:16:05

标签: java swt

我很难在tabfolder中获取可滚动区域....不知道我哪里出错...如果我得到一些帮助就会很棒......

    public void createCustomControl(Composite parent)
{
    parent.setLayout(new GridLayout());


    tabFolder = new TabFolder(parent, SWT.H_SCROLL |SWT.V_SCROLL);

    ScrolledComposite scroll = new ScrolledComposite(tabFolder, SWT.V_SCROLL|SWT.H_SCROLL);
    scroll.setExpandHorizontal(true);
    scroll.setExpandVertical(true);     
    GridData scrolledData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL
            | GridData.GRAB_VERTICAL);
    scroll.setLayoutData(scrolledData);

    Composite result = new Composite(scroll, SWT.NONE);
    GridData resultData = new GridData(GridData.FILL_BOTH |     GridData.GRAB_HORIZONTAL
            | GridData.GRAB_VERTICAL);
    result.setLayoutData(resultData);

    scroll.setContent(result);

    scroll.setMinSize(scroll.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

1 个答案:

答案 0 :(得分:0)

您需要创建TabItem并通过调用ScrolledComposite为其分配setControl()。选项卡文件夹仅在将子项分配给选项卡项时显示子项。

在代码末尾添加以下行:

final TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
tabItem.setControl(scroll);