Java Reference
In-Depth Information
CAUTION
If a
Composite
has no layout manager, each
Widget
in the
Composite
must have its size and position explicitly set, or else their sizes will default to
zero, and they will all be invisible! Tremendous details on SWT layout manager
classes can be found in the article “Understanding Layouts in SWT” by Carolyn
MacLeod and Shantha Ramachandran on the Eclipse Web site.
13
17.3.3.2
The
setStatus()
method is called whenever the data in the core model
changes. Its job is to update the UI to reflect those changes. More specifically,
it updates the status pane at the top of the UI. There are corresponding
methods for the list pane and the button pane.
Oddly, there are no changes in this particular method. The purpose of this
method is unchanged. It updates the
Label
s with the new numbers and checks
to see if the current
Account
is the top level
Account
. If it is, the
Up
button
is disabled, otherwise it is enabled.
It turns out that all of the methods called on the UI classes in this method
have the same names and purposes in Swing and SWT. Don't assume this will
be true in the other cases.
Converting the GUI
init()
Method
17.3.3.3
Finally, in the litany of conversion, we have to modify the event handlers. In
this case, the only event of interest is when the
Up
button is pressed. Pressing
a
Button
produces a
Selection
event.
In SWT, there are several types of events. Generally, you specify a class
that will handle the event by calling one of the
add...Listener()
methods
on the
Widget
that you wish to process the event for. Examples of these
method calls include:
Reworking Event Handlers
•
addSelectionListener()
•
addControlListener()
•
addFocusListener()
•
addHelpListener()
13.
http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20
Layouts.htm