JFrame Class
Package: javax.swing
The top-level component of most Swing-based applications is a “frame” and is defined by the JFrame class. By itself, a frame doesn’t do much, but to do anything else in Swing, you must first create a frame. Figure 5-6 shows a frame that does nothing but display the message Hello, World! in its title bar.

Figure 5-6
Constructors
|
Constructor |
Description |
|
|
Creates a new frame with no title |
|
|
Creates a new frame with the specified title |
Methods
|
Method |
Description |
|
|
Adds the specified component to the frame. |
|
|
Gets the menu for this frame. |
|
|
Adjusts the size of the frame to fit the components you added to it. |
|
|
Removes the specified component from the frame. |
|
|
Sets the action taken when the user closes the frame. You should almost always specify |
|
|
Sets the icon displayed when the frame is minimized. |
|
|
Sets the layout manager used to control how components are arranged when the frame is displayed. The default is the |
|
|
Sets the |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access