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 |
Get Java For Dummies Quick Reference 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.