Minimize to a Mini-Frame #40
Chapter 5, Windows, Dialogs, and Frames
|
207
HACK
When the user clicks the triangle at the bottom left, the More Info text area
appears, as seen in Figure 5-10.
H A C K
#40
Minimize to a Mini-Frame Hack #40
When you want your program to have a smaller window but still be on the
screen, try building a mini-mode.
Since the advent of iTunes, it seems that all consumer-oriented applications
must have meticulous interfaces that can dynamically adjust themselves.
Gone are the days of simply minimizing an application. Now your program
must have a small version rather than (or in addition to) hiding when mini-
mized. The smaller version contains limited controls but can fit nicely at the
bottom of the screen. This hack shows how to create a dynamic frame that
can switch properly between sizes for a more modern-looking interface.
JScrollPane scroller =
new JScrollPane (area,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
MoreInfoPanel mip = new MoreInfoPanel (grabbedContent, scroller);
dialog.setContentPane (mip);
dialog.pack( );
dialog.setVisible(true);
// dialog blocks on setVisible (JOptionPane makes it modal)
System.exit(0);
}
}
Figure 5-10. The Warning dialog after opening the MoreInfoPanel
Example 5-8. A spin-open dialog using a MoreInfoPanel (continued)

Get Swing Hacks now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.