繁体   English   中英

SWT / JFace Scrollview不滚动

[英]SWT / JFace Scrollview not scrolling

我有两个选项卡,分别具有各自的视图。 tabview本身在滚动视图中。 由于某些原因,较大的选项卡不会显示滚动条。 我像这样设置(工作)tabview:

public CustomerTab(Composite arg1, int arg2) throws SQLException {
    super(arg1, arg2);

    layout = new org.eclipse.swt.layout.GridLayout(GridData.FILL_BOTH, false);
    layout.numColumns = 1;
    this.setLayout(layout);

不会导致滚动条出现的那个开始像这样:

public InvoiceTab(Composite parent, int arg2) throws Exception {

    super(parent, arg2);

    // new gridlayout and asign to this tab
    gridLayout = new org.eclipse.swt.layout.GridLayout(GridData.FILL_BOTH, false);
    gridLayout.numColumns = 3;
    this.setLayout(gridLayout);

在我的应用程序中,我配置外壳程序:

@Override protected void configureShell(Shell shell) {

    super.configureShell(shell);
    shell.setSize(1130, 530);
    setShellStyle(SWT.SHELL_TRIM & (~SWT.RESIZE));
}

并以这种方式创建scrollview:

@Override protected Control createContents (Composite parent) {

    scrolledComp = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    mainContent = new Composite(scrolledComp, SWT.NONE);
    mainContent.setLayout(new FillLayout());

    mainTabView = null;
    mainTabView = new MainTabView(mainContent);

    scrolledComp.setContent(mainContent);
    scrolledComp.setExpandHorizontal(true);
    scrolledComp.setExpandVertical(true);
    scrolledComp.setMinSize(1100, 500);

    return mainTabView;
}

发生的情况是,滚动视图仅显示500的行程,但下面没有内容,没有滚动条。 有人可以看到我在做什么错吗?

提前感谢,马库斯

由于您将最小高度手动设置为500,因此ScrolledComposite不会更好。

您应使用内容的“实际”大小作为最小大小。 您可以使用以下代码:

scrolledComp.setContent(mainContent);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
scrolledComp.setMinSize(mainContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM