The JDialog Class

JDialog is the Swing version of its superclass, java.awt.Dialog. It provides the same key features described in Chapter 8 [2] in the discussion of JWindow, JFrame, and JApplet: it uses a JRootPane as its container, and it provides default window-closing behavior. Since JDialog extends java.awt.Dialog, it has a heavyweight peer and is managed by the native windowing system. Figure 10-1 shows how JDialog fits into the class hierarchy.

JDialog class diagram

Figure 10-1. JDialog class diagram

Properties

JDialog defines the properties and default values listed in Table 10-1. The content-Pane, glassPane, JMenuBar, and layeredPane properties are taken from rootPane, which is set to a new JRootPane by the constructor.

Table 10-1. JDialog properties

Property

Data type

get

is

set

Default value

accessibleContext o

AccessibleContext

·

  

JDialog.AccessibleJDialog( )

contentPane o

Container

·

 

·

From rootPane

defaultCloseOperation

int

·

 

·

HIDE_ON_CLOSE

defaultLookAndFeelDecorated s, 1.4

boolean

 

·

·

Depends on L&F, often false

glassPane o

Component

·

 

·

From rootPane

JMenuBar o

JMenuBar

·

 

·

null

layeredPane o

JLayeredPane

·

 

·

From rootPane

layout o

LayoutManager

·

 

·

BorderLayout

modal*

boolean

 

·

·

false

parent*

Container

·

  

SwingUtilities.get-SharedOwnerFrame( )

rootPane

JRootPane

·

  

JRootPane

title*

String

·

 

·

""

1.4since 1.4, ooverridden, sstatic

*Inherited from Dialog; can be set in JDialog ...

Get Java Swing, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.