I have a composite with GridLayout. On the first row there is just some text. On the second row there is a button. If i press the button i set the text on the first row to not visible, but everything stays in place. How can i "shrink" the composite so everything that is below the hidden text moves up to take its place?
Here is what i got so far:
public class Main {
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
final Composite composite = new Composite(shell, SWT.BORDER);
composite.setLayout(new GridLayout());
final Label label = new Label(composite, SWT.BORDER);
label.setText("Just some text");
Button b1 = new Button(composite, SWT.PUSH);
b1.setText("Button1");
b1.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
switch (e.type) {
case SWT.Selection:
label.setVisible(!label.getVisible());
break;
}
}
});
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}