APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JPanel

extends JComponent
implements Accessible
Class Inheritance
All Implemented Interfaces
javax.accessibility.Accessible
Known Direct Subclasses
javax.swing.JSpinner.DefaultEditor, javax.swing.colorchooser.AbstractColorChooserPanel, javax.swing.colorchooser.ColorPanel, javax.swing.colorchooser.DefaultPreviewPanel, javax.swing.colorchooser.SwatchPanel, javax.swing.plaf.basic.BasicTabbedPaneUI.ScrollableTabPanel, javax.swing.plaf.basic.BasicTabbedPaneUI.TabContainer, javax.swing.plaf.basic.BasicTabbedPaneUI.CroppedEdge, javax.swing.plaf.synth.SynthDesktopPaneUI.TaskBar, sun.swing.FilePane, com.sun.java.swing.plaf.gtk.GTKColorChooserPanel.ColorTriangle, com.sun.java.swing.plaf.motif.MotifDesktopIconUI.IconLabel, sun.print.ServiceDialog.GeneralPanel, sun.print.ServiceDialog.PrintServicePanel, sun.print.ServiceDialog.PrintRangePanel, sun.print.ServiceDialog.CopiesPanel, sun.print.ServiceDialog.PageSetupPanel, sun.print.ServiceDialog.MarginsPanel, sun.print.ServiceDialog.MediaPanel, sun.print.ServiceDialog.OrientationPanel, sun.print.ServiceDialog.AppearancePanel, sun.print.ServiceDialog.ChromaticityPanel, sun.print.ServiceDialog.QualityPanel, sun.print.ServiceDialog.SidesPanel, sun.print.ServiceDialog.JobAttributesPanel, sun.print.ServiceDialog.OutputPanel, sun.print.ServiceDialog.IconRadioButton, sun.awt.im.CompositionArea, javax.swing.JLayer.DefaultLayerGlassPane
Annotations
@JavaBean
defaultProperty:UI
description:A generic lightweight container.
@SuppressWarnings:serial
Imports
java.awt.FlowLayout, .LayoutManager, java.beans.BeanProperty, .JavaBean, java.io.IOException, .ObjectOutputStream, .Serial, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, javax.swing.plaf.PanelUI

JPanel is a generic lightweight container. For examples and task-oriented documentation for JPanel, see How to Use Panels, a section in The Java Tutorial.

Warning

Swing is not thread safe. For more information see Swing's Threading Policy.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Authors
Arnaud Weber, Steve Wilson
Since
1.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JPanel.AccessibleJPanel

This class implements accessibility support for the JPanel class.

Field Summary

Modifier and TypeField and Description
private static final String
Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerivSourceComponentlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JPanel(LayoutManager
the LayoutManager to use
layout
,
boolean
a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates
isDoubleBuffered
)

Creates a new JPanel with the specified layout manager and buffering strategy.

public
JPanel(LayoutManager
the LayoutManager to use
layout
)

Create a new buffered JPanel with the specified layout manager

public
JPanel(boolean
a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates
isDoubleBuffered
)

Creates a new JPanel with FlowLayout and the specified buffering strategy.

public
JPanel()

Creates a new JPanel with a double buffer and a flow layout.

Method Summary

Modifier and TypeMethod and Description
public AccessibleContext

Returns:

an AccessibleJPanel that serves as the AccessibleContext of this JPanel
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JPanel.

public PanelUI

Returns:

the PanelUI object that renders this component
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the look and feel (L&F) object that renders this component.

public String

Returns:

the string "PanelUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns a string that specifies the name of the L&F class that renders this component.

protected String

Returns:

a string representation of this JPanel.
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JPanel.

public void
setUI(PanelUI
the PanelUI L&F object
ui
)

Sets the look and feel (L&F) object that renders this component.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property with a value from the current look and feel.

private void
writeObject(ObjectOutputStream s)

Hides javax.swing.JComponent.writeObject.

See readObject() and writeObject() in JComponent for more information about serialization in Swing.

Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddNotifyaddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintBorderpaintChildrenpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveNotifyremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate

Field Detail

uiClassIDback to summary
private static final String uiClassID

Hides javax.swing.JComponent.uiClassID.

See Also
getUIClassID, readObject

Constructor Detail

JPanelback to summary
public JPanel(LayoutManager layout, boolean isDoubleBuffered)

Creates a new JPanel with the specified layout manager and buffering strategy.

Parameters
layout:LayoutManager

the LayoutManager to use

isDoubleBuffered:boolean

a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates

JPanelback to summary
public JPanel(LayoutManager layout)

Create a new buffered JPanel with the specified layout manager

Parameters
layout:LayoutManager

the LayoutManager to use

JPanelback to summary
public JPanel(boolean isDoubleBuffered)

Creates a new JPanel with FlowLayout and the specified buffering strategy. If isDoubleBuffered is true, the JPanel will use a double buffer.

Parameters
isDoubleBuffered:boolean

a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates

JPanelback to summary
public JPanel()

Creates a new JPanel with a double buffer and a flow layout.

Method Detail

getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JPanel. For JPanels, the AccessibleContext takes the form of an AccessibleJPanel. A new AccessibleJPanel instance is created if necessary.

Returns:AccessibleContext

an AccessibleJPanel that serves as the AccessibleContext of this JPanel

Annotations
@BeanProperty
bound:false
getUIback to summary
public PanelUI getUI()

Overrides javax.swing.JComponent.getUI.

Returns the look and feel (L&F) object that renders this component.

Returns:PanelUI

the PanelUI object that renders this component

Since
1.4
getUIClassIDback to summary
public String getUIClassID()

Overrides javax.swing.JComponent.getUIClassID.

Returns a string that specifies the name of the L&F class that renders this component.

Returns:String

the string "PanelUI"

Annotations
@BeanProperty
bound:false
expert:true
description:A string that specifies the name of the L&F class.
See Also
JComponent#getUIClassID, UIDefaults#getUI
paramStringback to summary
protected String paramString()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JPanel. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Returns:String

a string representation of this JPanel.

setUIback to summary
public void setUI(PanelUI ui)

Sets the look and feel (L&F) object that renders this component.

Parameters
ui:PanelUI

the PanelUI L&F object

Annotations
@BeanProperty
hidden:true
visualUpdate:true
description:The UI object that implements the Component\'s LookAndFeel.
Since
1.4
See Also
UIDefaults#getUI
updateUIback to summary
public void updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property with a value from the current look and feel.

See Also
JComponent#updateUI
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Hides javax.swing.JComponent.writeObject.

See readObject() and writeObject() in JComponent for more information about serialization in Swing.

Annotations
@Serial
Exceptions
IOException:

Doc from java.awt.Container.writeObject.

if an I/O error occurs

javax.swing back to summary

protected Class JPanel.AccessibleJPanel

extends AccessibleJComponent
Class Inheritance
Annotations
@SuppressWarnings:serial

This class implements accessibility support for the JPanel class. It provides an implementation of the Java Accessibility API appropriate to panel user-interface elements.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Field Summary

Inherited from javax.swing.JComponent.AccessibleJComponent:
accessibleFocusHandler

Constructor Summary

AccessConstructor and Description
protected
AccessibleJPanel()

Constructs an AccessibleJPanel.

Method Summary

Modifier and TypeMethod and Description
public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Inherited from javax.swing.JComponent.AccessibleJComponent:
addPropertyChangeListenergetAccessibleChildgetAccessibleChildrenCountgetAccessibleDescriptiongetAccessibleExtendedComponentgetAccessibleKeyBindinggetAccessibleNamegetAccessibleStateSetgetBorderTitlegetTitledBorderTextgetToolTipTextremovePropertyChangeListener

Constructor Detail

AccessibleJPanelback to summary
protected AccessibleJPanel()

Constructs an AccessibleJPanel.

Method Detail

getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object