Controls aus einer SWT Composite entfernen?

Thomas67

Grünschnabel
Hallo Leute,

will eine GUI dynamisch aufbauen und abbauen.

Der Aufbau ist soweit kein Problem nur zum entfernen der Controls hab ich nichts gefunden.

Gibts in SWT eine Möglichkeit komponenten aus einer SWT Composite oder Group wieder zu entfernen.

Bin um jeden Ratschlag dankbar.

Grüsse Thomas67
 
Hallo!

Schau mal hier:
Code:
/**
 * 
 */
package de.tutorials;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

/**
 * @author Administrator
 * 
 */
public class SWTRemoveComponentExample {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);

		shell.setText("SWTRemoveComponentExample");
		shell.setLayout(new GridLayout(1, true));

		final Button b0 = new Button(shell, SWT.PUSH);
		b0.setText("Button 0");
		Button b1 = new Button(shell, SWT.PUSH);
		b1.setText("Button 1");
		b1.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				b0.dispose();
				shell.layout();
			}
		});

		shell.pack();
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

}

Gruß Tom
 

Neue Beiträge

Zurück