JPanel Class
Package: javax.swing
The JPanel class defines a panel, which is a type of container designed to hold a group of components so they can be displayed in a frame. The normal way to display a group of controls — text fields, labels, buttons, and other GUI widgets — is to add those controls to a panel and then add the panel to the frame. You can bypass the panel and add the controls directly to the frame, but using a separate panel to hold the frame’s controls is almost always a good idea.
Constructors
|
Constructor |
Description |
|
|
Creates a new panel. |
|
|
Creates a new panel. If the parameter is |
|
|
Creates a new panel with the specified layout manager. The default layout manager is |
Methods
|
Method |
Description |
|
|
Adds the specified component to the panel. |
|
|
Removes the specified component from the panel. |
|
|
Sets the layout manager used to control how components are arranged when the panel 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