Java Reference
In-Depth Information
Creating a JFrame
The JFrame class provides two primary constructors: one for creating a frame without a title
and one for creating a frame with a title. There are two additional constructors for creating
frames with a specialized GraphicsConfiguration .
public JFrame()
JFrame frame = new JFrame();
public JFrame(String title)
JFrame frame = new JFrame("Title Bar");
public JFrame(GraphicsConfiguration config)
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gsd[] = ge.getScreenDevices();
GraphicsConfiguration gc[] = gsd[0].getConfigurations();
JFrame frame = new JFrame(gc[0]);
public JFrame(String title, GraphicsConfiguration config)
GraphicsConfiguration gc = ...;
JFrame frame = new JFrame("Title Bar", gc);
JFrame Properties
Table 8-5 shows the nine properties of the JFrame .
Table 8-5. JFrame Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
contentPane
Container
Read-write
defaultCloseOperation
int
Read-write
glassPane
Component
Read-write
iconImage
Image
Write-only
jMenuBar
JMenuBar
Read-write
layeredPane
JLayeredPane
Read-write
layout
LayoutManager
Write-only
rootPane
JRootPane
Read-only
Search WWH ::




Custom Search