添加滚动条到 JFACE 向导

发布于 2024-12-02 17:38:51 字数 1373 浏览 0 评论 0原文

问题

我的 WizardPage 中有一个 Composite,如果该 Composite 大于向导窗口,我想向其中添加滚动条,但到目前为止我尝试过的方法都不起作用。有人知道如何添加滚动条吗?

我想将它们添加到我添加文本的合成中;

compositeInfo = new Composite(container, SWT.BORDER);

我尝试

创建 ScrollableComposite 但没有成功,当我使用 ScrollableComponent 时,文本不会添加到 Composite 中。

compositeInfo = new ScrolledComposite(container, SWT.BORDER
                | SWT.H_SCROLL | SWT.V_SCROLL);
compositeInfo.setBackground(SWTResourceManager
            .getColor(SWT.COLOR_WHITE));

GridLayout gl = new GridLayout(1, false);
gl.numColumns = 1;
compositeInfo.setLayout(gl);
GridData gd_composite_2 = new GridData(SWT.CENTER, SWT.CENTER, false,
        false, 2, 1);
gd_composite_2.widthHint = 450;
compositeInfo.setLayoutData(gd_composite_2);

添加一些文字

c = compositeInfo;
Label lblGD = new Label(c, SWT.NONE);
GridData gd_lblG = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1,
                    1);
gd_lblG.widthHint = 450;
    lblGD.setLayoutData(gd_lblG);
    lblGD.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_BLUE));
    lblGD.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
    lblGD.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    lblGD.setAlignment(SWT.LEFT);
    lblGD.setText(t);
    ((ScrolledComposite) c).setContent(lblGD);

Problem

I have a Composite in my wizardPage and I want to add scrollbars to it if the Composite is bigger than the wizard window, but no method I tried so far worked. Anyone an idea how to add the scrollbars?

I want to add them to a Composite to which I add text;

compositeInfo = new Composite(container, SWT.BORDER);

What I tried

I tried creating a ScrollableComposite without succes, when I use the ScrollableComponent, the text doesnt get added to the Composite.

compositeInfo = new ScrolledComposite(container, SWT.BORDER
                | SWT.H_SCROLL | SWT.V_SCROLL);
compositeInfo.setBackground(SWTResourceManager
            .getColor(SWT.COLOR_WHITE));

GridLayout gl = new GridLayout(1, false);
gl.numColumns = 1;
compositeInfo.setLayout(gl);
GridData gd_composite_2 = new GridData(SWT.CENTER, SWT.CENTER, false,
        false, 2, 1);
gd_composite_2.widthHint = 450;
compositeInfo.setLayoutData(gd_composite_2);

add some text

c = compositeInfo;
Label lblGD = new Label(c, SWT.NONE);
GridData gd_lblG = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1,
                    1);
gd_lblG.widthHint = 450;
    lblGD.setLayoutData(gd_lblG);
    lblGD.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_BLUE));
    lblGD.setFont(SWTResourceManager.getFont("Tahoma", 10, SWT.BOLD));
    lblGD.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
    lblGD.setAlignment(SWT.LEFT);
    lblGD.setText(t);
    ((ScrolledComposite) c).setContent(lblGD);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳公公是暖光 2024-12-09 17:38:51

请参阅 ScrolledComposite。您需要调用compositeInfo.setSizecompositeInfo.setMinSize

See JavaDoc of ScrolledComposite. You need to call either compositeInfo.setSize or compositeInfo.setMinSize.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文