I am trying to create a container which will contain a buttons in it after certain amount of buttons I want to get a scroll bar but at the moment scroll bar is not appearing any suggestions?
EDIT
MoBuConLTLUI Class
public class MoBuConLTLUI extends Composite {
public MoBuConLTLUI(Composite parent) {
super(parent, SWT.NONE);
this.setLayout(new GridLayout());
createScrollableComposite(parent);
}
public void createScrollableComposite (Composite parent) {
// set the size of the scrolled content - method 1
final ScrolledComposite sc1 = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite c1 = new Composite(sc1, SWT.V_SCROLL);
sc1.setContent(c1);
sc1.setMinSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
GridLayout layout = new GridLayout();
layout.numColumns = 1;
c1.setLayout(layout);
Button b1 = new Button (c1, SWT.PUSH);
b1.setText("first button");
c1.setSize(200,200);
Button add = new Button (parent, SWT.PUSH);
add.setText("add children");
final int[] index = new int[]{0};
add.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
index[0]++;
Button button = new Button(c1, SWT.PUSH);
button.setText("button "+index[0]);
// reset size of content so children can be seen - method 1
c1.layout();
}
});
}
}
EDIT The parent is initialized like following
public class TestBundleUI extends AbstractEntryPoint{
private static final long serialVersionUID = -7954149221017272321L;
private Composite testUiParentComposite;
@Override
public void createContents(Composite parent) {
this.testUiParentComposite = parent;
testUiParentComposite.setLayout(new GridLayout());
new MoBuConLTLUI(parent);
}
}