gpt4 book ai didi

java - SWT/JFace Scrollview 不滚动

转载 作者:太空宇宙 更新时间:2023-11-04 08:03:59 24 4
gpt4 key购买 nike

我有两个选项卡,它们有各自的 View 。选项卡 View 本身位于 ScrollView 中。由于某种原因,较大的选项卡不会显示滚动条。我像这样设置(工作)选项卡 View :

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

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

@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;
}

发生的情况是, ScrollView 仅显示 500 处,但下面没有内容,也没有滚动条。有人能看到我做错了什么吗?

提前致谢,马库斯

最佳答案

由于您手动将最小高度设置为 500,ScrolledComposite 无法更好地了解。

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

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

关于java - SWT/JFace Scrollview 不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12384766/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com