Add scrollbar to JFACE Wizard
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);
See JavaDoc of ScrolledComposite
. You need to call either compositeInfo.setSize
or compositeInfo.setMinSize
.
精彩评论