O'Reilly logo

Swing Hacks by Chris Adamson, Joshua Marinacci

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required