简体   繁体   English

SWT / JFace Scrollview不滚动

[英]SWT / JFace Scrollview not scrolling

I have two tabs with their own respective views. 我有两个选项卡,分别具有各自的视图。 The tabview itself is in a scrollview. tabview本身在滚动视图中。 For some reason, the scrollbars don't appear for the larger tab. 由于某些原因,较大的选项卡不会显示滚动条。 I set up the (working) tabview like so: 我像这样设置(工作)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);

The one, that's not causing the scrollbars to appear, starts like so: 不会导致滚动条出现的那个开始像这样:

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);

In my application, I configure the shell: 在我的应用程序中,我配置外壳程序:

@Override protected void configureShell(Shell shell) {

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

and create the scrollview this way: 并以这种方式创建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;
}

What happens, is that the scrollview just displays as far the 500 go, but no content below, no scrollbars. 发生的情况是,滚动视图仅显示500的行程,但下面没有内容,没有滚动条。 Can anybody see, what I'm doing wrong? 有人可以看到我在做什么错吗?

Thanx in advance, Marcus 提前感谢,马库斯

Since you set you minimum height manually to 500, the ScrolledComposite doesn't know better. 由于您将最小高度手动设置为500,因此ScrolledComposite不会更好。

You should use the "real" size of the content as minimum size. 您应使用内容的“实际”大小作为最小大小。 You can use the following code: 您可以使用以下代码:

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