![]() | The Java Developer's Guide to Eclipse |
In Chapter 14, The Standard Widget Toolkit: A Lean Mean Widget Machine,
you learned the fundamentals of SWT. This SWT widgets example demonstrates some
commonly used widgets
(Button, Composite, Display,
FileDialog, Font, Group,
List, ProgressBar, Shell, and StyledText)
and their event listeners. It also demonstrates synchronization of UI and non-UI threads using
the Display class. Also see the companion projects
com.ibm.jdg2e.swt.layouts and com.ibm.jdg2e.swt.snippets (containing nearly 250 SWT examples).:

To run the example, make sure the project com.ibm.jdg2e.swt is in your workspace. From the Plug-in Development perspective, launch
the run-time instance of Eclipse (Run > Run As > Eclipse Application) . Select Window > Show View > Other… Then, expand JDG2E and select SWT Example. The view should display. Double click on
the view title bar so the view occupies the
entire workbench window. In several cases,
when you interact with the widgets in the
view, information is displayed in the Console
view of the launch instance of Eclipse.
An Eclipse view is used as the widget container even though the book discusses
views in a later chapter. You can ignore this for now. Start your investigation
of the code with the open method in the SWTView class.
StyledText text widget with its own Font. A ModifyListener and ControlListener are associated with the widget. The font must follow widget disposal requirements.
List widget and illustrates the use of SWT style bits.
ProgressBar widget and the use of the Display.sync and Display.async methods to control UI and non-UI thread interaction.
The example is contained in a single class in the com.ibm.jdg2e.swt package.
| Class | Description |
SWTView |
Displays the view JDG2E: SWT Example |
© Copyright International Business Machines Corporation, 2003, 2004, 2006. All Rights Reserved.
Code or samples provided herein are provided without warranty of any kind.