添加滚动条到 JFACE 向导
问题
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅
ScrolledComposite
。您需要调用compositeInfo.setSize
或compositeInfo.setMinSize
。See JavaDoc of
ScrolledComposite
. You need to call eithercompositeInfo.setSize
orcompositeInfo.setMinSize
.