java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
- 所有已实现的接口:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
@JavaBean(defaultProperty="UI", description="A generic lightweight container.") public class JPanel extends JComponent implements Accessible
JPanel
是一个通用的轻量级容器。有关 JPanel 的示例和面向任务的文档,请参阅 如何使用面板,这是 The Java Tutorial 中的一个部分。
警告: Swing 不是线程安全的。更多信息请参阅 Swing 的线程策略。
警告: 该类的序列化对象将不兼容未来的 Swing 版本。当前的序列化支持适用于短期存储或在运行相同 Swing 版本的应用程序之间的 RMI。从 1.4 版本开始,已将所有 JavaBeans 的长期存储支持添加到 java.beans
包中。请参阅 XMLEncoder
。
- 自:
- 1.2
-
Nested Class Summary
Nested classes/interfaces declared in class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces declared in class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces declared in class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields declared in class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields declared in class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields declared in interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
ConstructorDescriptionJPanel()
创建一个带有双缓冲和流布局的新JPanel
。JPanel
(boolean isDoubleBuffered) 创建一个带有FlowLayout
和指定缓冲策略的新JPanel
。JPanel
(LayoutManager layout) 创建一个带有指定布局管理器的新缓冲 JPanelJPanel
(LayoutManager layout, boolean isDoubleBuffered) 创建一个带有指定布局管理器和缓冲策略的新 JPanel。 -
Method Summary
Methods declared in class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods declared in class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods declared in class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
JPanel
创建一个带有指定布局管理器和缓冲策略的新 JPanel。- 参数:
-
layout
- 要使用的布局管理器 -
isDoubleBuffered
- 一个布尔值,对于双缓冲,它使用额外的内存空间以实现快速、无闪烁的更新
-
JPanel
创建一个带有指定布局管理器的新缓冲 JPanel- 参数:
-
layout
- 要使用的布局管理器
-
JPanel
public JPanel(boolean isDoubleBuffered) 创建一个带有FlowLayout
和指定缓冲策略的新JPanel
。如果isDoubleBuffered
为 true,则JPanel
将使用双缓冲。- 参数:
-
isDoubleBuffered
- 一个布尔值,对于双缓冲,它使用额外的内存空间以实现快速、无闪烁的更新
-
JPanel
public JPanel()创建一个带有双缓冲和流布局的新JPanel
。
-
-
Method Details
-
updateUI
public void updateUI()使用当前外观的值重置 UI 属性。- 覆盖:
-
updateUI
在类JComponent
中 - 另请参阅:
-
getUI
返回渲染此组件的外观(L&F)对象。- 覆盖:
-
getUI
在类JComponent
中 - 返回:
- 渲染此组件的 PanelUI 对象
- 自:
- 1.4
-
setUI
@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the Component\'s LookAndFeel.") public void setUI(PanelUI ui) 设置渲染此组件的外观(L&F)对象。- 参数:
-
ui
- PanelUI L&F 对象 - 自:
- 1.4
- 另请参阅:
-
getUIClassID
@BeanProperty(bound=false, expert=true, description="A string that specifies the name of the L&F class.") public String getUIClassID()返回一个字符串,指定渲染此组件的外观(L&F)类的名称。- 覆盖:
-
getUIClassID
在类JComponent
中 - 返回:
- 字符串 "PanelUI"
- 另请参阅:
-
paramString
返回此 JPanel 的字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能因实现而异。返回的字符串可能为空,但不能为null
。- 覆盖:
-
paramString
在类JComponent
中 - 返回:
- 此 JPanel 的字符串表示形式。
-
getAccessibleContext
获取与此 JPanel 关联的 AccessibleContext。对于 JPanels,AccessibleContext 采用 AccessibleJPanel 的形式。如有必要,将创建一个新的 AccessibleJPanel 实例。- 指定者:
-
getAccessibleContext
在接口Accessible
中 - 覆盖:
-
getAccessibleContext
在类Component
中 - 返回:
- 作为此 JPanel 的 AccessibleContext 的 AccessibleJPanel
-