FileDocCategorySizeDatePackage
JPanel.javaAPI DocJava SE 5 API6882Fri Aug 26 14:57:56 BST 2005javax.swing

JPanel

public class JPanel extends JComponent implements Accessible
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: 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 JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.

beaninfo
description: A generic lightweight container.
version
1.46 12/19/03
author
Arnaud Weber
author
Steve Wilson

Fields Summary
private static final String
uiClassID
Constructors Summary
public JPanel(LayoutManager layout, boolean isDoubleBuffered)
Creates a new JPanel with the specified layout manager and buffering strategy.

param
layout the LayoutManager to use
param
isDoubleBuffered a boolean, true for double-buffering, which uses additional memory space to achieve fast, flicker-free updates


                                                             
         
        setLayout(layout);
        setDoubleBuffered(isDoubleBuffered);
        setUIProperty("opaque", Boolean.TRUE);
        updateUI();
    
public JPanel(LayoutManager layout)
Create a new buffered JPanel with the specified layout manager

param
layout the LayoutManager to use

        this(layout, true);
    
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.

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

        this(new FlowLayout(), isDoubleBuffered);
    
public JPanel()
Creates a new JPanel with a double buffer and a flow layout.

        this(true);
    
Methods Summary
public javax.accessibility.AccessibleContextgetAccessibleContext()
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.

return
an AccessibleJPanel that serves as the AccessibleContext of this JPanel

        if (accessibleContext == null) {
            accessibleContext = new AccessibleJPanel();
        }
        return accessibleContext;
    
public javax.swing.plaf.PanelUIgetUI()
Returns the look and feel (L&F) object that renders this component.

return
the PanelUI object that renders this component
since
1.4

        return (PanelUI)ui;
    
public java.lang.StringgetUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.

return
"PanelUI"
see
JComponent#getUIClassID
see
UIDefaults#getUI
beaninfo
expert: true description: A string that specifies the name of the L&F class.

        return uiClassID;
    
protected java.lang.StringparamString()
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.

return
a string representation of this JPanel.

	return super.paramString();
    
public voidsetUI(javax.swing.plaf.PanelUI ui)
Sets the look and feel (L&F) object that renders this component.

param
ui the PanelUI L&F object
see
UIDefaults#getUI
since
1.4
beaninfo
bound: true hidden: true attribute: visualUpdate true description: The UI object that implements the Component's LookAndFeel.

        super.setUI(ui);
    
public voidupdateUI()
Resets the UI property with a value from the current look and feel.

see
JComponent#updateUI

        setUI((PanelUI)UIManager.getUI(this));
    
private voidwriteObject(java.io.ObjectOutputStream s)
See readObject() and writeObject() in JComponent for more information about serialization in Swing.

        s.defaultWriteObject();
        if (getUIClassID().equals(uiClassID)) {
            byte count = JComponent.getWriteObjCounter(this);
            JComponent.setWriteObjCounter(this, --count);
            if (count == 0 && ui != null) {
                ui.installUI(this);
            }
        }