Java Reference
In-Depth Information
Key SWT Abstractions
Composite
is one of the key abstractions in SWT. Any control that may
contain other controls is a
Composite
.
Here's a quick rundown of the key abstract classes and interfaces in
SWT, along with the basics of the functionality they embody:
•A
Widget
is the abstract superclass of all user interface objects in
SWT. At this level the methods exist that create, dispose, and dis-
patch events to listeners. Every single class we use in this chapter,
with the exception of event handlers and layout managers, is a
Widget
.
•A
Control
is the abstract superclass of all windowed user interface
classes. This is almost all of the UI classes, either by direct descent
or through classes such as
Sash
or
Scrollable
. All constructors
for
Control
classes require a
Composite
parent class as a construc-
tor argument.
•A
Composite
is a
Control
which is capable of containing other
Control
s. One direct descendant of
Control
which is very similar
to the Swing
JPanel
is
Group
.
The relationships and the power of these abstractions will become
clear as you work with real-life examples.
(well, maybe not really skyrocket, since the
import
changes have already
produced a lot of errors right off the bat).
Finally, we remove the
AbstractTableModel
member. SWT has a
simpler (and more limited) table functionality that we will discuss later.
Step 2: Converting the
main()
Method
17.3.2
The main (pun unintended) changes that need to be made here include allocat-
ing the SWT
Display
, changing from instantiating a
JFrame
to a
Shell
,
doing away with the Swing “look and feel” stuff (an SWT application always
looks like a platform-native application, that's SWT's main selling point), and
reworking the construction of the GUI. We'll explain that a little bit later.
For now, we take care of the simple changes. Remember that
main()
is a
static method, so we do not have any nonstatic class members available right