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

Make Frames Resize Dynamically #100
Chapter 12, Miscellany
|
501
HACK
A Word About Speed
When you have dynamic layout turned on, the window will repaint each
time the user moves the mouse. This will make the application feel respon-
sive because there is always information on the screen being updated. If your
frame contains an animated component, it will continue to play while the
user resizes the window.
The disadvantage of dynamic layout is that a resize will generate a whole lot
of repaint requests in a very short time. Even if the user moves the window
just one pixel, it will trigger a repaint on the entire frame (unlike scrolling,
which usually requires just repainting a strip at the bottom). If your paint-
ing code is slow (or you have a lot of components on screen), then the
dynamic layout could actually make your program feel slower. Be sure you
make your painting as fast as possible, perhaps skipping some of the more
complicated effects during the resize. You may also want to use dynamic lay-
out only in a program with a small streamlined window, such as a media
player or utility app.

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