Basic RootPaneContainers

For the rest of this chapter, we’ll look at some basic containers (JFrame, JWindow, and JApplet) that implement RootPaneContainer and use JRootPane. First, we’ll take a quick look at a simple interface called WindowConstants.

The WindowConstants Interface

WindowConstants is a simple interface containing only constants. It is implemented by JFrame, JDialog, and JInternalFrame.

Constants

The constants defined in WindowConstants specify possible behaviors in response to a window being closed. These values are shown in Table 8-7.

Table 8-7. JWindowConstants constants

Constant

Type

Description

DISPOSE_ON_CLOSE

int

Disposes window when closed

DO_NOTHING_ON_CLOSE

int

Does nothing when closed

EXIT_ON_CLOSE1.4, *

int

Exits the virtual machine when closed

HIDE_ON_CLOSE

int

Hides window when closed

1.4since 1.4

*This constant was added in 1.4, although a matching constant was defined in the 1.3 JFrame class.

  

In the next section, we’ll look at a strategy for exiting the application in response to a frame being closed .

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.