WindowBuilder supports visual inheritance of
SWT Shells and Composites, Swing JFrames,
JDialogs, JApplets and JPanels, and GWT
Composites. Visual inheritance
supports the following features:
|
|
|
The following is an example of two Composites in an inheritance hierarchy. The first Composite uses a GridLayout and has two Labels, two Text widgets, a Button and an inner Composite widget.
The inner Composite widget has been exposed as a public component using the Expose Component command. Expose Component converts a component to a field and adds a public accessor for it. Finally, the background color property of the first Text widget and the text property of the Button have been exposed as a public properties of the Composite using the Expose Property command. Expose Property adds a pair of accessors for getting and setting the desired property of the target widget.
The second Composite inherits from
the first and sets the inner Composite's layout manager via
its accessor from the superclass and then adds several new widgets
to the inner Composite. It also adds several new widgets that appear after the
inherited widgets and use the GridLayout layout manager inherited
from the superclass. Finally, it overrides the background color for
the first Text widget and the text setting of the Button using the accessors defined in the first Composite.
public ChildComposite(Composite parent, int style) { final GridLayout gridLayout = new GridLayout(); thirdField = new Text(getComposite(), SWT.BORDER); final GridData gd_thirdField = new GridData(SWT.FILL, SWT.CENTER, true, false); thirdField.setLayoutData(gd_thirdField); final Label fourthFieldLabel = new Label(getComposite(), SWT.NONE); fourthField = new Text(getComposite(), SWT.BORDER); final GridData gd_fourthField = new GridData(SWT.FILL, SWT.CENTER, true, false); fourthField.setLayoutData(gd_fourthField); list = new List(getComposite(), SWT.BORDER); list.setItems(new String[] {"First Item", "Second Item"}); list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1)); final Label fifthFieldLabel = new Label(this, SWT.NONE); fifthField = new Text(this, SWT.BORDER); final GridData gd_fifthField = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); fifthField.setLayoutData(gd_fifthField); final Label sixthFieldLabel = new Label(this, SWT.NONE); sixthField = new Text(this, SWT.BORDER); final GridData gd_sixthField = new GridData(SWT.FILL, SWT.CENTER, true, false); sixthField.setLayoutData(gd_sixthField); final Button searchButton = new Button(this, SWT.NONE); |
|