I have a view, where elements are displayed, depending on previous choices. dispose() and parent.layout() do get rid of elements as expected. Question is, how do I get them back? I suppose, dispose() doesn't delete an element, just takes it out of the elements list to render. So, how can I get one back?
Thanx in advance, Marcus
Edit:
Just found, that dispose() frees the object and recursively it's children, so I have to recreate them, once I have them disposed? If so, how can I find the position inside a e.g. GridLayout?
Edit(2):
According to the answer below, I have tried this:
public class TestTab extends Composite
{
org.eclipse.swt.layout.GridLayout layout = null;
GridData griddata = null;
Button upperButton = null;
Text textInTheMiddle = null;
Button lowerButton = null;
public InvoiceTab(Composite parent, int arg2) {
super(parent, arg2);
final Composite myParent = parent;
layout = new org.eclipse.swt.layout.GridLayout(GridData.FILL_BOTH,
false);
layout.numColumns = 1;
this.setLayout(layout);
upperButton = new Button(this, SWT.PUSH);
upperButton.setText("upper Button");
textInTheMiddle = new Text(this, SWT.BORDER);
lowerButton = new Button(this, SWT.PUSH);
lowerButton.setText("lower Button");
upperButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (textInTheMiddle.isVisible()) {
textInTheMiddle.setVisible(false);
lowerButton.moveBelow(upperButton);
} else {
textInTheMiddle.setVisible(true);
lowerButton.moveBelow(textInTheMiddle);
}
myParent.layout();
}
});
}
}
The textfield gest visible as expected, but the lower button doesn't change place? Thanx again for any thoughts...