< Zurück | Inhalt | Weiter >

17.3.4 Completing the Conversion of the BudgetPro Class

To keep this book 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. The Table, TableColumn, and TableItem Classes

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

model. This will be your biggest challenge. Go to it. It is a great way to learn. Of course, you can also just download the complete SWT application from the book Web site.15