
Add Status Bars to Windows #36
Chapter 5, Windows, Dialogs, and Frames
|
187
HACK
H A C K
#36
Add Status Bars to Windows
Hack #36
Lots of applications use a bottom-of-window panel to communicate status.
But Swing doesn’t provide a consistent way to do this. So, you need to
provide it yourself.
Many applications in Microsoft Windows use a status bar—an area at the
bottom of each window (to the left of the resize box if there is one) that can
be used to communicate summary information to the user in a compact
form. Typical contents of a status bar might include what a web browser is
doing (e.g., “Connecting to www.oreilly.com”), or, as in Figure 5-6, a sum-
mary of the contents of a folder, showing the number of contained items,
their size, etc.
Standard Status Bars
This is the standard MS Windows setup for a status bar:
• An icon on the far right letting users know they can resize the application
• A label on the left for free form text
• Several labels on the right for details (e.g., 42.3 MB in Figure 5-6)
There is also a bit of custom painting involved to get the top and bottom
shading right. First, you’ll do the panel shading, and then loop back to the
previous list and add all of the necessary components to the status bar.
This hack copies the Windows Explorer status bar in Win-
dows XP. Different applications are slightly different. The
purpose of this hack isn’t to start a religious war about
which application ...