我的wizardPage中有一个Composite,如果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);
答案 0 :(得分:2)
参见ScrolledComposite
的JavaDoc。您需要拨打compositeInfo.setSize
或compositeInfo.setMinSize
。