Java Reference
In-Depth Information
JWindow Properties
Table 8-7 lists the six properties of
JWindow
. These are similar in nature to the
JFrame
properties,
except that
JWindow
has no property for a default close operation or a menu bar.
Table 8-7.
JWindow Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
contentPane
Container
Read-write
glassPane
Component
Read-write
layeredPane
JLayeredPane
Read-write
layout
LayoutManager
Write-only
rootPane
JRootPane
Read-only
Handling JWindow Events
The
JWindow
class adds no additional event-handling capabilities beyond those of the
JFrame
and
Window
classes. See the “Handling JFrame Events” section earlier in this chapter for a list of
listeners you can attach to a
JWindow
.
Extending JWindow
If you need to extend
JWindow
, the class has two
protected
methods of importance:
protected void windowInit()
protected JRootPane createRootPane()
JDialog Class
The
JDialog
class represents the standard pop-up window for displaying information related
to a
Frame
. It acts like a
JFrame
, whereby its
JRootPane
contains a content pane and an optional
JMenuBar
, and it implements the
RootPaneContainer
and
WindowConstants
interfaces.
Creating a JDialog
There are 11 constructors for creating
JDialog
windows:
public JDialog()
JDialog dialog = new JDialog();
public JDialog(Dialog owner)
JDialog dialog = new JDialog(anotherDialog);