Java Reference
In-Depth Information
Table 8-13.
JInternalFrame.DesktopIcon UIResource Elements
Property String
Object Type
DesktopIcon.background
Color
DesktopIcon.border
Border
DesktopIcon.font
Font
DesktopIcon.foreground
Color
DesktopIcon.icon
Icon
DesktopIcon.width
Integer
DesktopIcon.windowBindings
Object[ ]
DesktopIconUI
String
JDesktopPane Class
Another class for working with groups of internal frames is the
JDesktopPane
class. The sole
purpose of the desktop pane is to contain a set of internal frames. When internal frames are
contained within a desktop pane, they delegate most of their behavior to the desktop manager
of the desktop pane. You'll also learn about the
DesktopManager
interface in greater detail later
in this chapter.
Creating a JDesktopPane
The
JDesktopPane
has a single no-argument constructor. Once it's created, you'd typically
place the desktop in the center of a container managed by a
BorderLayout
. This ensures that
the desktop takes up all the room in the container.
Adding Internal Frames to a JDesktopPane
The
JDesktopPane
doesn't implement
RootPaneContainer
. Instead of adding components to the
different panes within a
JRootPane
, you add them directly to the
JDesktopPane
:
desktop.add(anInternalFrame);
JDesktopPane Properties
As Table 8-14 shows, there are eight properties of
JDesktopPane
. The
JInternalFrame
at index 0
of the
allFrames
property array is the internal frame in front of the desktop (
JInternalFrame f
= desktop.getAllFrames()[0]
). Besides getting all the frames within the
JDesktopPane
, you can
get only those within a specific layer:
public JInternalFrame[] getAllFramesInLayer(int layer)
.
(Remember
JLayeredPane
, covered earlier in this chapter in the “Working with Component Layers
and Positions” section, the parent class of
JDesktopPane
?)
Valid
dragMode
property settings are the
LIVE_DRAG_MODE
and
OUTLINE_DRAG_MODE
constants
of the class.