
Debug Components with a Custom Glass Pane #96
Chapter 12, Miscellany
|
481
HACK
from/subject of one email message, the details of a downloaded file, etc.). In
cases like these, I’ll try to see if a
JList with a multi-line cell renderer [Hack #16]
can keep all the data together in a visually pleasing form. So, when is hori-
zontal scrolling OK? I think it’s appropriate when the data you’re displaying
is not row-oriented, and instead you’re scrolling up, down, and across a
single cohesive thing, like a large image or, in this case, a stack trace.
H A C K
#96
Debug Components with a Custom Glass PaneHack #96
Show component boundaries at runtime using a glass pane.
Sometimes when I’m building a really complicated Swing layout, I start to
lose track of what I’m looking at. Which component is this? Does that panel
extend all the way to the end of the frame? A way to visualize the layout
would be a useful addition to the usual development tools. This hack
explores using a custom glass pane to highlight each component and its
classname.
A glass pane is a normally transparent Swing component that is drawn on
top of all of the other components in a frame, as you saw when you put
dialog-like “sheets” into the glass pane
[Hack #44]. It is this ability that forms
the center of the hack. The custom glass pane will traverse the entire tree of
components in the frame, filling a translucent rectangle over each compo-
nent. ...