- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JRootPane
-
- 实现的所有接口
-
ImageObserver,MenuContainer,Serializable,Accessible
public class JRootPane extends JComponent implements Accessible
通过在后台使用一个轻量级容器JFrame,JDialog,JWindow,JApplet和JInternalFrame。 有关根窗格提供的功能的面向任务的信息,请参阅“Java教程”中的 How to Use Root Panes部分。下图显示了使用根窗格的类之间的关系。
“重量级”组件(委托给对等方的组件或主机系统上的本机组件)显示为更暗,更重的盒子。 四个重量级JFC / Swing容器(
JFrame,JDialog,JWindow,和JApplet)被示出相对于它们扩展AWT类。 这四个组件是Swing库中唯一的重量级容器。 还示出了轻质容器JInternalFrame。 所有这五个JFC / Swing容器都实现了RootPaneContainer接口,它们都将操作委托给JRootPane(顶部带有一个小“句柄”)。Note: The
ExampleJComponentmethodgetRootPanecan be used to obtain theJRootPanethat contains a given component.
右图显示了JRootPane的结构。JRootpane由glassPane,可选menuBar和contentPane。 (JLayeredPane管理menuBar和contentPane)glassPane位于所有内容的顶部,它可以拦截鼠标移动。 由于glassPane(如contentPane)可以是任意组件,因此也可以设置glassPane进行绘图。 然后,glassPane上的线条和图像可以在下面的帧上进行范围调整,而不受其边界的限制。虽然
menuBar组件是可选的,该layeredPane,contentPane和glassPane始终存在。 尝试将它们设置为null生成异常。要将组件添加到
JRootPane(可选菜单栏除外),请将对象添加到contentPane的JRootPane,如下所示:rootPane.getContentPane().add(child);同样的原则适用于设置布局管理器,删除组件,列出子项等。所有这些方法都在contentPane上调用,而不是在JRootPane上JRootPane。Note: The default layout manager for the
如果contentPaneis aBorderLayoutmanager. However, theJRootPaneuses a customLayoutManager. So, when you want to change the layout manager for the components you added to aJRootPane, be sure to use code like this:rootPane.getContentPane().setLayout(new BoxLayout());JMenuBar部件被设定在JRootPane,它沿框的上边缘定位。contentPane位置和大小进行了调整,以填补剩余的区域。 (JMenuBar和contentPane被添加到JLayeredPane.FRAME_CONTENT_LAYER层的layeredPane组件中。)layeredPane是layeredPane中所有子项的父JRootPane- 既作为菜单的直接父项,又添加到contentPane的所有组件的祖父contentPane。 它是JLayeredPane一个实例,它提供了在多个层添加组件的功能。 使用菜单弹出窗口,对话框和拖动时,此功能非常有用 - 在这种情况下,您需要将组件放在窗格中的所有其他组件之上。glassPane位于glassPane中所有其他组件的JRootPane。 这为在所有其他组件上方绘制提供了一个方便的位置,并且可以拦截鼠标事件,这对于拖动和绘图都很有用。 开发人员可以使用setVisible上的glassPane来控制glassPane显示在其他子项上的时间。 默认情况下,glassPane不可见。自定义
LayoutManager通过使用JRootPane确保:-
glassPane填充了JRootPane(bounds-insets)的整个可视区域。 - 该
layeredPane充满整个可视区域JRootPane。 (界限 - 插图) - 所述
menuBar位于的上边缘layeredPane。 -
contentPane填充整个可视区域,减去menuBar(如果存在)。
JRootPane视图层次结构中的任何其他视图。如果更换
LayoutManager的JRootPane,则您负责管理所有这些视图。 因此,通常您需要确保更改contentPane的布局管理器而不是JRootPane本身!Swing的绘制体系结构要求在所有其他组件上方的包含层次结构中存在不透明的
JComponent。 这通常通过内容窗格提供。 如果替换内容窗格,建议您通过setOpaque(true)使内容窗格不透明。 此外,如果内容窗格覆盖paintComponent,则需要在paintComponent中以不透明的颜色完全填充背景。警告: Swing不是线程安全的。 有关更多信息,请参阅Swing's Threading Policy 。
警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,
java.beans软件包中添加了对所有JavaBeansjava.beans长期存储的支持。 请参阅XMLEncoder。- 从以下版本开始:
- 1.2
- 另请参见:
-
JLayeredPane,JMenuBar,JWindow,JFrame,JDialog,JApplet,JInternalFrame,JComponent,BoxLayout, Mixing Heavy and Light Components , Serialized Form
-
-
嵌套类汇总
嵌套类 变量和类型 类 描述 protected classJRootPane.AccessibleJRootPane此类实现JRootPane类的可访问性支持。protected classJRootPane.RootLayout自定义布局管理器,负责layeredPane,glassPane和menuBar的布局。-
嵌套类/接口声明在类 javax.swing.JComponent
JComponent.AccessibleJComponent
-
嵌套类/接口声明在类 java.awt.Container
Container.AccessibleAWTContainer
-
-
字段汇总
字段 变量和类型 字段 描述 static intCOLOR_CHOOSER_DIALOG用于windowDecorationStyle属性的常量。protected ContainercontentPane内容窗格。protected JButtondefaultButton窗格具有焦点时激活的按钮以及按 Enter键的特定于UI的操作。static intERROR_DIALOG用于windowDecorationStyle属性的常量。static intFILE_CHOOSER_DIALOG用于windowDecorationStyle属性的常量。static intFRAME用于windowDecorationStyle属性的常量。protected ComponentglassPane覆盖菜单栏和内容窗格的玻璃窗格,因此它可以拦截鼠标移动等。static intINFORMATION_DIALOG用于windowDecorationStyle属性的常量。protected JLayeredPanelayeredPane用于管理菜单栏和内容窗格的分层窗格。protected JMenuBarmenuBar菜单栏。static intNONE用于windowDecorationStyle属性的常量。static intPLAIN_DIALOG用于windowDecorationStyle属性的常量。static intQUESTION_DIALOG用于windowDecorationStyle属性的常量。static intWARNING_DIALOG用于windowDecorationStyle属性的常量。-
声明的属性在类 javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
声明的属性在类 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
-
-
构造方法摘要
构造方法 构造器 描述 JRootPane()创建JRootPane,建立其glassPane,layeredPane和contentPane。
-
方法摘要
所有方法 实例方法 具体的方法 弃用的方法 变量和类型 方法 描述 protected voidaddImpl(Component comp, Object constraints, int index)重写以强制将玻璃组件的位置设置为零子项。protected ContainercreateContentPane()由构造函数方法调用以创建默认值contentPane。protected ComponentcreateGlassPane()由构造函数方法调用以创建默认值glassPane。protected JLayeredPanecreateLayeredPane()由构造函数方法调用以创建默认值layeredPane。protected LayoutManagercreateRootLayout()由构造函数方法调用以创建默认值layoutManager。AccessibleContextgetAccessibleContext()获取AccessibleContext与此相关JRootPane。ContainergetContentPane()返回内容窗格 - 容纳由根窗格作为父级的组件的容器。JButtongetDefaultButton()返回defaultButton属性的值。ComponentgetGlassPane()返回此JRootPane的当前玻璃窗格。JMenuBargetJMenuBar()从分层窗格返回菜单栏。JLayeredPanegetLayeredPane()获取根窗格使用的分层窗格。JMenuBargetMenuBar()已过时。截至Swing 1.0.3版由getJMenuBar()取代。RootPaneUIgetUI()返回呈现此组件的L&F对象。StringgetUIClassID()返回一个字符串,该字符串指定呈现此组件的L&F类的名称。intgetWindowDecorationStyle()返回一个常量,标识JRootPane提供的Window装饰类型。booleanisOptimizedDrawingEnabled()glassPane和contentPane具有相同的边界,这意味着JRootPane不会平铺其子JRootPane,这应该返回false。booleanisValidateRoot()如果此JRootPane的后代调用revalidate,请从此处开始验证。protected StringparamString()返回此JRootPane的字符串表示JRootPane。voidsetContentPane(Container content)设置内容窗格 - 容纳由根窗格作为父级的组件的容器。voidsetDefaultButton(JButton defaultButton)设置defaultButton属性,该属性确定此JRootPane的当前默认按钮。voidsetDoubleBuffered(boolean aFlag)设置此组件是否应使用缓冲区进行绘制。voidsetGlassPane(Component glass)将指定的Component设置为此根窗格的玻璃窗格。voidsetJMenuBar(JMenuBar menu)添加或更改分层窗格中使用的菜单栏。voidsetLayeredPane(JLayeredPane layered)设置根窗格的分层窗格。voidsetMenuBar(JMenuBar menu)已过时。截至Swing版本1.0.3由setJMenuBar(JMenuBar menu)取代。voidsetUI(RootPaneUI ui)设置呈现此组件的L&F对象。voidsetWindowDecorationStyle(int windowDecorationStyle)设置JRootPane应提供的窗口装饰类型(如边框,关闭窗口的小部件,标题...)。voidupdateUI()将UI属性重置为当前外观的值。-
声明方法的类 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
声明方法的类 java.awt.Container
add, add, add, add, add, addContainerListener, 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
-
声明方法的类 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, hide, 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
-
-
-
-
字段详细信息
-
NONE
public static final int NONE
用于windowDecorationStyle属性的常量。 表示JRootPane不应提供任何种类的窗口装饰。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
FRAME
public static final int FRAME
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合Frame的装饰。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
PLAIN_DIALOG
public static final int PLAIN_DIALOG
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合Dialog的装饰。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
INFORMATION_DIALOG
public static final int INFORMATION_DIALOG
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合用于显示信息性消息的对话框的装饰。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
ERROR_DIALOG
public static final int ERROR_DIALOG
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合用于显示错误消息的Dialog的装饰。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
COLOR_CHOOSER_DIALOG
public static final int COLOR_CHOOSER_DIALOG
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合用于显示JColorChooser的对话框的JColorChooser。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
FILE_CHOOSER_DIALOG
public static final int FILE_CHOOSER_DIALOG
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合用于显示JFileChooser的对话框的JFileChooser。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
QUESTION_DIALOG
public static final int QUESTION_DIALOG
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合用于向用户提出问题的Dialog的装饰。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
WARNING_DIALOG
public static final int WARNING_DIALOG
用于windowDecorationStyle属性的常量。 表示JRootPane应提供适合用于显示警告消息的对话框的装饰。- 从以下版本开始:
- 1.4
- 另请参见:
- 常数字段值
-
menuBar
protected JMenuBar menuBar
菜单栏。
-
contentPane
protected Container contentPane
内容窗格。
-
layeredPane
protected JLayeredPane layeredPane
用于管理菜单栏和内容窗格的分层窗格。
-
glassPane
protected Component glassPane
覆盖菜单栏和内容窗格的玻璃窗格,因此它可以拦截鼠标移动等。
-
defaultButton
protected JButton defaultButton
窗格具有焦点时激活的按钮以及按 Enter键的特定于UI的操作。
-
-
方法详细信息
-
setDoubleBuffered
public void setDoubleBuffered(boolean aFlag)
设置此组件是否应使用缓冲区进行绘制。 如果设置为true,则此组件中的所有绘图都将在屏幕外绘制缓冲区中完成。 屏幕外的绘画缓冲区将被复制到屏幕上。 如果Component被缓冲并且其祖先之一也被缓冲,则将使用祖先缓冲区。- 重写:
-
setDoubleBuffered类JComponent - 参数
-
aFlag- 如果为true,则将此组件设置为双缓冲 - 从以下版本开始:
- 1.6
-
getWindowDecorationStyle
public int getWindowDecorationStyle()
返回一个常量,标识JRootPane提供的Window装饰类型。- 结果
-
一个
NONE,FRAME,PLAIN_DIALOG,INFORMATION_DIALOG,ERROR_DIALOG,COLOR_CHOOSER_DIALOG,FILE_CHOOSER_DIALOG,QUESTION_DIALOG或WARNING_DIALOG。 - 从以下版本开始:
- 1.4
- 另请参见:
-
setWindowDecorationStyle(int)
-
setWindowDecorationStyle
@BeanProperty(expert=true, visualUpdate=true, enumerationValues={"JRootPane.NONE","JRootPane.FRAME","JRootPane.PLAIN_DIALOG","JRootPane.INFORMATION_DIALOG","JRootPane.ERROR_DIALOG","JRootPane.COLOR_CHOOSER_DIALOG","JRootPane.FILE_CHOOSER_DIALOG","JRootPane.QUESTION_DIALOG","JRootPane.WARNING_DIALOG"}, description="Identifies the type of Window decorations to provide") public void setWindowDecorationStyle(int windowDecorationStyle)
设置JRootPane应提供的窗口装饰类型(如边框,关闭窗口的小部件,标题...)。 默认设置是不提供Window装饰(NONE)。这只是一个暗示,一些外观和感觉可能不支持这一点。 这是一个绑定属性。
- 参数
-
windowDecorationStyle- 不断识别要提供的窗口装饰。 - 异常
-
IllegalArgumentException-如果style不是一个:NONE,FRAME,PLAIN_DIALOG,INFORMATION_DIALOG,ERROR_DIALOG,COLOR_CHOOSER_DIALOG,FILE_CHOOSER_DIALOG,QUESTION_DIALOG,或WARNING_DIALOG。 - 从以下版本开始:
- 1.4
- 另请参见:
-
JDialog.setDefaultLookAndFeelDecorated(boolean),JFrame.setDefaultLookAndFeelDecorated(boolean),LookAndFeel.getSupportsWindowDecorations()
-
getUI
public RootPaneUI getUI()
返回呈现此组件的L&F对象。- 重写:
-
getUI在类JComponent - 结果
-
LabelUI对象 - 从以下版本开始:
- 1.3
-
setUI
@BeanProperty(expert=true, hidden=true, visualUpdate=true, description="The UI object that implements the Component\'s LookAndFeel.") public void setUI(RootPaneUI ui)
设置呈现此组件的L&F对象。- 参数
-
ui-LabelUIL&F对象 - 从以下版本开始:
- 1.3
- 另请参见:
-
UIDefaults.getUI(javax.swing.JComponent)
-
updateUI
public void updateUI()
将UI属性重置为当前外观的值。- 重写:
-
updateUI在类JComponent - 另请参见:
-
JComponent.updateUI()
-
getUIClassID
public String getUIClassID()
返回一个字符串,该字符串指定呈现此组件的L&F类的名称。- 重写:
-
getUIClassID在类JComponent - 结果
- 字符串“RootPaneUI”
- 另请参见:
-
JComponent.getUIClassID(),UIDefaults.getUI(javax.swing.JComponent)
-
createLayeredPane
protected JLayeredPane createLayeredPane()
由构造方法调用以创建默认值layeredPane。 Bt默认它创建一个新的JLayeredPane。- 结果
-
默认
layeredPane
-
createContentPane
protected Container createContentPane()
由构造函数方法调用以创建默认值contentPane。 默认情况下,此方法创建一个新的JComponent添加集BorderLayout作为其LayoutManager。- 结果
-
默认
contentPane
-
createGlassPane
protected Component createGlassPane()
由构造函数方法调用以创建默认值glassPane。 默认情况下,此方法会创建一个新的JComponent,其可见性设置为false。- 结果
-
默认
glassPane
-
createRootLayout
protected LayoutManager createRootLayout()
由构造函数方法调用以创建默认值layoutManager。- 结果
-
默认
layoutManager。
-
setJMenuBar
public void setJMenuBar(JMenuBar menu)
添加或更改分层窗格中使用的菜单栏。- 参数
-
menu- 要添加的JMenuBar
-
setMenuBar
@Deprecated public void setMenuBar(JMenuBar menu)
Deprecated.As of Swing version 1.0.3 replaced bysetJMenuBar(JMenuBar menu).指定菜单栏值。- 参数
-
menu- 要添加的JMenuBar。
-
getJMenuBar
public JMenuBar getJMenuBar()
从分层窗格返回菜单栏。- 结果
-
窗格中使用的
JMenuBar
-
getMenuBar
@Deprecated public JMenuBar getMenuBar()
Deprecated.As of Swing version 1.0.3 replaced bygetJMenuBar().返回菜单栏值。- 结果
-
窗格中使用的
JMenuBar
-
setContentPane
public void setContentPane(Container content)
设置内容窗格 - 容纳由根窗格作为父级的组件的容器。Swing的绘画架构在包含层次结构中需要不透明的
JComponent。 这通常由内容窗格提供。 如果更换内容窗格,建议您使用不透明的JComponent替换它。- 参数
-
content- 用于组件内容的Container - 异常
-
IllegalComponentStateException- (运行时异常),如果内容窗格参数为null
-
getContentPane
public Container getContentPane()
返回内容窗格 - 容纳由根窗格作为父级的组件的容器。- 结果
-
保存组件内容的
Container
-
setLayeredPane
public void setLayeredPane(JLayeredPane layered)
设置根窗格的分层窗格。 分层窗格通常包含内容窗格和可选的JMenuBar。- 参数
-
layered- 使用JLayeredPane - 异常
-
IllegalComponentStateException- (运行时异常),如果分层窗格参数为null
-
getLayeredPane
public JLayeredPane getLayeredPane()
获取根窗格使用的分层窗格。 分层窗格通常包含内容窗格和可选的JMenuBar。- 结果
-
目前正在使用的
JLayeredPane
-
setGlassPane
public void setGlassPane(Component glass)
将指定的Component设置为此根窗格的玻璃窗格。 玻璃窗格通常应该是一个轻量级的透明组件,因为当根窗格需要抓取输入事件时,它将变为可见。新玻璃窗格的可见性将更改为与当前玻璃窗格的可见性相匹配。 这意味着当您想要更换玻璃窗格并使其可见时必须小心。 以下任何一种都可以使用:
root.setGlassPane(newGlassPane); newGlassPane.setVisible(true);要么:root.getGlassPane().setVisible(true); root.setGlassPane(newGlassPane);- 参数
-
glass-Component的玻璃窗格的JRootPane - 异常
-
NullPointerException- 如果glass参数是null
-
getGlassPane
public Component getGlassPane()
返回此JRootPane的当前玻璃窗格。- 结果
- 目前的玻璃窗格
- 另请参见:
-
setGlassPane(java.awt.Component)
-
isValidateRoot
public boolean isValidateRoot()
如果此JRootPane的后代调用revalidate,请从此处进行验证。延迟再次布局组件及其后代的请求。 例如,对
revalidate调用会向上推送到JRootPane或JScrollPane因为这两个类都会覆盖isValidateRoot以返回true。- 重写:
-
isValidateRoot在类JComponent - 结果
- 真正
- 另请参见:
-
JComponent.isValidateRoot(),Container.isValidateRoot()
-
isOptimizedDrawingEnabled
public boolean isOptimizedDrawingEnabled()
glassPane和contentPane具有相同的边界,这意味着JRootPane不会平铺其子JRootPane,这应该返回false。 另一方面,glassPane通常不可见,因此如果glassPane不可见,则返回true。 因此,此处的返回值取决于glassPane的可见性。- 重写:
-
isOptimizedDrawingEnabled在类JComponent - 结果
- 如果此组件的子项不重叠,则为true
-
setDefaultButton
@BeanProperty(description="The button activated by default in this root pane") public void setDefaultButton(JButton defaultButton)
设置defaultButton属性,该属性确定此JRootPane的当前默认按钮。 默认按钮是当根窗格中出现UI定义的激活事件(通常是Enter键)时将激活的按钮,无论该按钮是否具有键盘焦点(除非根窗格中有另一个组件消耗激活事件,例如JTextPane)。 要使默认激活起作用,当激活发生时,该按钮必须是根窗格的启用后代。 要从此根窗格中删除默认按钮,请将此属性设置为null。- 参数
-
defaultButton-JButton,它是默认按钮 - 另请参见:
-
JButton.isDefaultButton()
-
getDefaultButton
public JButton getDefaultButton()
返回defaultButton属性的值。- 结果
-
JButton,这是当前的默认按钮 - 另请参见:
-
setDefaultButton(javax.swing.JButton)
-
addImpl
protected void addImpl(Component comp, Object constraints, int index)
重写以强制将玻璃组件的位置设置为零子项。- 重写:
-
addImpl在类Container - 参数
-
comp- 要增强的组件 -
constraints- 要遵守的约束 -
index- 该指数 - 另请参见:
-
Container.add(Component),Container.add(Component, int),Container.add(Component, java.lang.Object),Container.invalidate(),LayoutManager,LayoutManager2
-
paramString
protected String paramString()
返回此JRootPane的字符串表示JRootPane。 此方法仅用于调试目的,返回字符串的内容和格式可能因实现而异。 返回的字符串可能为空,但可能不是null。- 重写:
-
paramString在类JComponent - 结果
-
此
JRootPane的字符串表示JRootPane。
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
获取AccessibleContext与这个JRootPane相关联。 为根窗格,所述AccessibleContext需要一个的形式AccessibleJRootPane。 如有必要,将创建新的AccessibleJRootPane实例。- Specified by:
-
getAccessibleContext在接口Accessible - 重写:
-
getAccessibleContext在类Component - 结果
-
AccessibleJRootPane,作为AccessibleContext的JRootPane
-
-