Java Reference
In-Depth Information
by the
JDesktopIcon
inner class of
JInternalFrame
. There are also an
InternalFrameListener
,
InternalFrameAdapter
, and
InternalFrameEvent
for event handling.
First, let's look at the parts that make up the desktop, and then you'll see a complete example
that uses all the parts.
■
Note
The Swing libraries provide only those tools necessary to build an application using MDI. You use
these tools in whatever manner you see fit.
JInternalFrame Class
The
JInternalFrame
class is similar to the
JFrame
class. It acts as a high-level container, using
the
RootPaneContainer
interface, but it isn't a top-level window. You must place internal frames
within another top-level window. When dragged around, internal frames stay within the bounds
of their container, which is usually a
JDesktopPane
. In addition, internal frames are lightweight
and therefore offer a UI-delegate to make internal frames appear as the currently configured
look and feel.
■
Note
As with the creation of a
JFrame
, the
JInternalFrame
is hidden when first created.
Creating a JInternalFrame
There are six constructors for
JInternalFrame
:
public JInternalFrame()
JInternalFrame frame = new JInternalFrame();
public JInternalFrame(String title)
JInternalFrame frame = new JInternalFrame("The Title");
public JInternalFrame(String title, boolean resizable)
JInternalFrame frame = new JInternalFrame("The Title", true);
public JInternalFrame(String title, boolean resizable, boolean closable)
JInternalFrame frame = new JInternalFrame("The Title", false, true);
public JInternalFrame(String title, boolean resizable, boolean
closable, boolean maximizable)
JInternalFrame frame = new JInternalFrame("The Title", true, false, true);
public JInternalFrame(String title, boolean resizable, boolean
closable, boolean maximizable, boolean iconifiable)
JInternalFrame frame = new JInternalFrame("The Title", false, true, false, true);