|
Re: ScrolledComposite in TitleAreaDialog [message #1244276 is a reply to message #1232177] |
Wed, 12 February 2014 00:28  |
Eclipse User |
|
|
|
Hi,
It seems you didn't set any layout for the scroll composite, that's why you couldn't get to see the end of the vertical scroll bar, or the horizontal scroll bar.
Also, when I did set the layout, the scroll bars appeared in disabled mode. Turned out, you were re-sizing it incorrectly.
Find the correct code, working as you want, below.
public class TestDialog extends TitleAreaDialog {
public TestDialog(Shell parentShell) {
super(parentShell);
}
@Override
protected Control createDialogArea(Composite parent) {
parent.setLayout(new GridLayout());
Composite superParent = (Composite) super.createDialogArea(parent);
final ScrolledComposite scrollComposite = new ScrolledComposite(superParent, SWT.V_SCROLL | SWT.BORDER | SWT.H_SCROLL);
scrollComposite.setAlwaysShowScrollBars(true);
scrollComposite.setLayoutData(new GridData(SWT.NONE, SWT.NONE, true, true));
scrollComposite.setLayout(new GridLayout());
final Composite container = new Composite(scrollComposite, SWT.NONE);
GridLayout layout=new GridLayout();
layout.numColumns=1;
container.setLayout(layout);
for(int i = 0; i <= 50; i++) {
Label label = new Label(container, SWT.NONE);
label.setLayoutData(new GridData());
if (i % 3 == 0) label.setImage(ImageUtils.ICON_ENTE_COLLETTIVO);
if (i % 3 == 1) label.setImage(ImageUtils.ICON_NUOVA_PRATICA);
if (i % 3 == 2) label.setImage(ImageUtils.ICON_PERSONE);
}
scrollComposite.setContent(container);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);
scrollComposite.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
scrollComposite.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
});
return scrollComposite;
}
@Override
protected Point getInitialSize() {
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int screenHeight = screenSize.height;
int screenWidth = screenSize.width;
return new Point(screenWidth/2, screenHeight);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.05067 seconds