Java Reference
In-Depth Information
have additional space contributed to text areas. Consider a word processor:
When you resize its window you only want the text area to expand, not the
menus and icons.
Layout managers are meant to address the issues of component placement
and sizing. Some are very simple, others are much more complex. All have their
advantages and disadvantages. We'll use a few in our example to give you a taste
of how they work.
16.6
B EYOND A RTHUR M URRAY : A CTIONS , L ISTENERS , E VENTS
With any serious GUI comes a lot of advanced Java, especially constructs like
anonymous inner classes. These are useful when we implement actions for our
buttons and listeners for user selections.
Keep in mind that there are three different time frames that we're consid-
ering—compile time, construction time, and event time. Compile time is obvi-
ous, and the compiler will complain if it cannot access what it needs due to
scoping problems. Construction time is when the program constructs the GUI
objects for display in a window using the new and add() calls as well as layout
managers. Event time is when the user presses a button or edits text in a field,
or when other external events change data.
16.7
G ETTING D OWN TO C ASES : D ESIGNING A GUI FOR B UDGET P RO
Our goal is a GUI for the BudgetPro application. We've already built a com-
mand-line version, so we want to have the same general functions but with the
convenience 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 account
From this brief list we devise a simple display with a heading that contains
the current account and its dollar status, a table which lists the subaccounts,
Search WWH ::




Custom Search