13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

394Chapter 17Other Ways: Alternatives to SwingExample 17.2 The upt<strong>on</strong> Butt<strong>on</strong> event listener class reference declarati<strong>on</strong>private Selecti<strong>on</strong>Listener upActi<strong>on</strong> = new Selecti<strong>on</strong>Adapter(){public void widgetSelected(Selecti<strong>on</strong>Event e){// this is the acti<strong>on</strong> for UP arrow ic<strong>on</strong>;Account next;next = current.getParent();if (next != null) {current = next;setStatus();}}} ;17.3.4 Completing the C<strong>on</strong>versi<strong>on</strong> of the BudgetPro ClassTo keep this book to a reas<strong>on</strong>able size, we are always trying to avoid coveringthe same ground more than <strong>on</strong>ce. We w<strong>on</strong>’t walk you through the details ofc<strong>on</strong>verting the createList() and createButt<strong>on</strong>s() methods as we did withthe createStatus() method, but we will talk about the details of c<strong>on</strong>vertingto SWT of some of the classes used in those methods.17.3.4.1 The Table, TableColumn, and TableItem ClassesWithout a doubt, the biggest change the BudgetPro class requires in order toc<strong>on</strong>vert from Swing to SWT lies in the table pane of the UI. The Table classis the root of tables in SWT. The TableColumn class defines the names andheaders of the columns. TableColumn c<strong>on</strong>structors must have a Table as theirfirst argument, followed, as usual, by a numeric style specificati<strong>on</strong>. TheTableItem class defines a row in the Table. As with TableColumn, theTableItem c<strong>on</strong>structor must have a Table as its first argument, followed bya numeric style.If you think about it, this is an extensi<strong>on</strong> of the same design philosophythat requires that all c<strong>on</strong>structors name their parent Composite. While Swing’sabstract table model permits a nice separati<strong>on</strong> between the data and the presentati<strong>on</strong>,implementing a similar system in SWT would violate its strict c<strong>on</strong>tainersemantics.You will need to follow the basic rewrite process outlined above and youwill have to squish the Swing abstract table model into the simpler SWT table

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!