The SWidgets constructors take two parameters: the parent of the widget or NULL if the parent is the Display and a style parameter. To implement an SWidget, perform the following steps:
- Create an instance of the widget.
// Create an instance of an SButton
SButton button = new SButton(parent, SWT.PUSH);
- Add the button to the application user interface.
- After the widget is used, dispose of it.
// Dispose of the SButton since it’s no longer needed
Eclipse also provides several facilities to enable resource sharing among components. For example, if several widgets must access the same Color, the Color can be added to, and referenced from, the JFace color registry. This allows one Color instance to be shared by any number of widgets. Resources that are shared should never be disposed. JFace provides these registries for fonts, images, and colors.
Parent topic: Extending the capabilities of your application: XPD622