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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

348Chapter 16Getting in the Swing of Things: Designing a GUI for BudgetProhave additi<strong>on</strong>al space c<strong>on</strong>tributed to text areas. C<strong>on</strong>sider a word processor:When you resize its window you <strong>on</strong>ly want the text area to expand, not themenus and ic<strong>on</strong>s.Layout managers are meant to address the issues of comp<strong>on</strong>ent placementand sizing. Some are very simple, others are much more complex. All have theiradvantages and disadvantages. We’ll use a few in our example to give you a tasteof how they work.16.6BEYOND ARTHUR MURRAY: ACTIONS, LISTENERS, EVENTSWith any serious GUI comes a lot of advanced Java, especially c<strong>on</strong>structs likean<strong>on</strong>ymous inner classes. These are useful when we implement acti<strong>on</strong>s for ourbutt<strong>on</strong>s and listeners for user selecti<strong>on</strong>s.Keep in mind that there are three different time frames that we’re c<strong>on</strong>sidering—compiletime, c<strong>on</strong>structi<strong>on</strong> time, and event time. Compile time is obvious,and the compiler will complain if it cannot access what it needs due toscoping problems. C<strong>on</strong>structi<strong>on</strong> time is when the program c<strong>on</strong>structs the GUIobjects for display in a window using the new and add() calls as well as layoutmanagers. Event time is when the user presses a butt<strong>on</strong> or edits text in a field,or when other external events change data.16.7GETTING DOWN TO CASES: DESIGNING A GUI FOR BUDGETPROOur goal is a GUI for the BudgetPro applicati<strong>on</strong>. We’ve already built a command-lineversi<strong>on</strong>, so we want to have the same general functi<strong>on</strong>s but with thec<strong>on</strong>venience and glamour of a GUI. The GUI will need to:• Display the current account (name and dollars)• Display the list of subaccounts that are part of this account• Provide a way to create a new (sub)account• Provide a way to move down into a subaccount• Provide a way to move up to the parent accountFrom this brief list we devise a simple display with a heading that c<strong>on</strong>tainsthe current account and its dollar status, a table which lists the subaccounts,

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

Saved successfully!

Ooh no, something went wrong!