Java Reference
In-Depth Information
Example 17.2
The
upton Button
event listener class reference declaration
private SelectionListener upAction = new SelectionAdapter()
{
public void widgetSelected(SelectionEvent e)
{
// this is the action for UP arrow icon;
Account next;
next = current.getParent();
if (next != null) {
current = next;
setStatus();
}
}
} ;
Completing the Conversion of the
BudgetPro
Class
17.3.4
To keep this topic to a reasonable size, we are always trying to avoid covering
the same ground more than once. We won't walk you through the details of
converting the
createList()
and
createButtons()
methods as we did with
the
createStatus()
method, but we will talk about the details of converting
to SWT of some of the classes used in those methods.
17.3.4.1
Without a doubt, the biggest change the
BudgetPro
class requires in order to
convert from Swing to SWT lies in the table pane of the UI. The
Table
class
is the root of tables in SWT. The
TableColumn
class defines the names and
headers of the columns.
TableColumn
constructors must have a
Table
as their
first argument, followed, as usual, by a numeric style specification. The
TableItem
class defines a row in the
Table
. As with
TableColumn
, the
TableItem
constructor must have a
Table
as its first argument, followed by
a numeric style.
If you think about it, this is an extension of the same design philosophy
that requires that all constructors name their parent
Composite
. While Swing's
abstract table model permits a nice separation between the data and the presen-
tation, implementing a similar system in SWT would violate its strict container
semantics.
You will need to follow the basic rewrite process outlined above and you
will have to squish the Swing abstract table model into the simpler SWT table
The
Table
,
TableColumn
, and
TableItem
Classes