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 |
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.