- 所有已实现的接口:
-
ImageObserver
,MenuContainer
,Serializable
,Accessible
JInternalFrame
对象并将它们添加到JDesktopPane
中。JDesktopPane
扩展了JLayeredPane
以管理潜在重叠的内部框架。它还维护了一个由当前外观和感觉(L&F)的UI类设置的DesktopManager
实例的引用。请注意,JDesktopPane
不支持边框。
通常将此类用作JInternalFrames
的父级,以为JInternalFrames
提供可插拔的DesktopManager
对象。L&F特定实现的installUI
负责适当设置desktopManager
变量。当JInternalFrame
的父级是JDesktopPane
时,它应该将大部分行为委托给desktopManager
(关闭、调整大小等)。
有关更多文档和示例,请参见如何使用内部框架,这是The Java Tutorial中的一个部分。
警告: Swing不是线程安全的。更多信息请参见Swing的线程策略。
警告: 该类的序列化对象将不兼容未来的Swing版本。当前的序列化支持适用于短期存储或在运行相同Swing版本的应用程序之间的RMI。从1.4开始,已将所有JavaBeans的长期存储支持添加到java.beans
包中。请参见XMLEncoder
。
- 自:
- 1.2
- 参见:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
该类实现了JDesktopPane
类的辅助功能支持。Nested classes/interfaces declared in class javax.swing.JLayeredPane
JLayeredPane.AccessibleJLayeredPane
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
Modifier and TypeFieldDescriptionstatic final int
表示应在桌面窗格内完全显示正在拖动的项目的内容。static final int
表示应在桌面窗格内仅显示正在拖动的项目的轮廓。Fields declared in class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
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
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
将指定的组件添加到此容器的指定索引处。获取与此JDesktopPane
关联的AccessibleContext
。返回当前在桌面中显示的所有JInternalFrames
。getAllFramesInLayer
(int layer) 返回当前在桌面指定层中显示的所有JInternalFrames
。返回处理桌面特定UI操作的DesktopManger
。int
获取桌面窗格使用的当前“拖动样式”。返回此JDesktopPane
中当前活动的JInternalFrame
,如果当前没有活动的JInternalFrame
,则返回null
。getUI()
返回呈现此组件的L&F对象。返回呈现此组件的L&F类的名称。protected String
返回此JDesktopPane
的字符串表示形式。void
remove
(int index) 从此窗格中删除索引组件。void
从此容器中删除所有组件。selectFrame
(boolean forward) 选择此桌面窗格中的下一个JInternalFrame
。void
setComponentZOrder
(Component comp, int index) 将指定的组件移动到容器中指定的Z顺序索引处。void
设置将处理桌面特定UI操作的DesktopManger
。void
setDragMode
(int dragMode) 设置桌面窗格使用的“拖动样式”。void
设置此JDesktopPane
中当前活动的JInternalFrame
。void
setUI
(DesktopPaneUI ui) 设置呈现此组件的L&F对象。void
updateUI()
来自UIManager
的通知,L&F已更改。Methods declared in class javax.swing.JLayeredPane
getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, putLayer, setLayer, setLayer, setPosition
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, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, 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, removeContainerListener, 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
-
Field Details
-
LIVE_DRAG_MODE
public static final int LIVE_DRAG_MODE表示应在桌面窗格内完全显示正在拖动的项目的内容。- 参见:
-
OUTLINE_DRAG_MODE
public static final int OUTLINE_DRAG_MODE表示应在桌面窗格内仅显示正在拖动的项目的轮廓。- 参见:
-
-
Constructor Details
-
JDesktopPane
public JDesktopPane()创建一个新的JDesktopPane
。
-
-
Method Details
-
getUI
返回呈现此组件的L&F对象。- 覆盖:
-
getUI
在类JComponent
- 返回:
-
渲染此组件的
DesktopPaneUI
对象
-
setUI
@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the Component\'s LookAndFeel.") public void setUI(DesktopPaneUI ui) 设置呈现此组件的L&F对象。- 参数:
-
ui
- DesktopPaneUI L&F对象 - 参见:
-
setDragMode
@BeanProperty(enumerationValues={"JDesktopPane.LIVE_DRAG_MODE","JDesktopPane.OUTLINE_DRAG_MODE"}, description="Dragging style for internal frame children.") public void setDragMode(int dragMode) 设置桌面窗格使用的“拖动样式”。您可能希望出于性能或美观原因切换到一种模式或另一种模式。- 参数:
-
dragMode
- 用于桌面中项目的拖动样式 - 自:
- 1.3
- 参见:
-
getDragMode
public int getDragMode()获取桌面窗格使用的当前“拖动样式”。- 返回:
-
Live_DRAG_MODE
或OUTLINE_DRAG_MODE
- 自:
- 1.3
- 参见:
-
getDesktopManager
返回处理桌面特定UI操作的DesktopManger
。- 返回:
-
处理桌面特定UI操作的
DesktopManger
-
setDesktopManager
@BeanProperty(description="Desktop manager to handle the internal frames in the desktop pane.") public void setDesktopManager(DesktopManager d) 设置将处理桌面特定UI操作的DesktopManger
。这可能会被LookAndFeel
覆盖。- 参数:
-
d
- 要使用的DesktopManager
-
updateUI
public void updateUI()来自UIManager
的通知,L&F已更改。用最新版本从UIManager
替换当前UI对象。- 覆盖:
-
updateUI
在类JComponent
- 参见:
-
getUIClassID
返回呈现此组件的L&F类的名称。- 覆盖:
-
getUIClassID
在类JComponent
- 返回:
- 字符串“DesktopPaneUI”
- 参见:
-
getAllFrames
返回当前在桌面中显示的所有JInternalFrames
。返回缩小的框架以及展开的框架。- 返回:
-
一个
JInternalFrame
对象数组
-
getSelectedFrame
返回此JDesktopPane
中当前活动的JInternalFrame
,如果当前没有活动的JInternalFrame
,则返回null
。- 返回:
-
当前活动的
JInternalFrame
或null
- 自:
- 1.3
-
setSelectedFrame
设置此JDesktopPane
中当前活动的JInternalFrame
。此方法用于在JDesktopPane和平台实现代码之间建立包间隙,并且不应直接调用。要可视地选择框架,客户端必须调用JInternalFrame.setSelected(true)来激活框架。- 参数:
-
f
- 当前选定的内部框架 - 自:
- 1.3
- 参见:
-
getAllFramesInLayer
返回当前在桌面指定层中显示的所有JInternalFrames
。返回缩小的框架以及展开的框架。- 参数:
-
layer
- 指定桌面层的整数 - 返回:
-
一个
JInternalFrame
对象数组 - 参见:
-
selectFrame
选择此桌面窗格中的下一个JInternalFrame
。- 参数:
-
forward
- 一个布尔值,指示选择的方向;true
表示向前,false
表示向后 - 返回值:
-
被选中的JInternalFrame或者
null
(如果没有选中任何内容) - 自版本:
- 1.6
-
addImpl
将指定的组件添加到此容器的指定索引处。此方法还通过addLayoutComponent
方法通知布局管理器,使用指定的约束对象将组件添加到此容器的布局中。约束由使用的特定布局管理器定义。例如,
BorderLayout
类定义了五个约束:BorderLayout.NORTH
、BorderLayout.SOUTH
、BorderLayout.EAST
、BorderLayout.WEST
和BorderLayout.CENTER
。GridBagLayout
类需要一个GridBagConstraints
对象。未能传递正确类型的约束对象会导致IllegalArgumentException
。如果当前布局管理器实现了
LayoutManager2
,则会在其上调用LayoutManager2.addLayoutComponent(Component,Object)
。如果当前布局管理器没有实现LayoutManager2
,并且约束是一个String
,则会在其上调用LayoutManager.addLayoutComponent(String,Component)
。如果组件不是此容器的祖先并且具有非空父级,则在将其添加到此容器之前,将其从当前父级中移除。
这是要覆盖的方法,如果程序需要跟踪对容器的每个添加请求,因为所有其他添加方法都会推迟到这个方法。覆盖方法通常应包括对该方法的超类版本的调用:
super.addImpl(comp, constraints, index)
此方法更改与布局相关的信息,因此会使组件层次结构无效。如果容器已经显示,那么必须在此后验证层次结构,以便显示添加的组件。
-
remove
public void remove(int index) 从此窗格中删除索引组件。这是绝对索引,忽略层。- 覆盖:
-
remove
在类JLayeredPane
- 参数:
-
index
- 指定要移除的组件的整数 - 自版本:
- 1.6
- 参见:
-
removeAll
public void removeAll()从此容器中删除所有组件。- 覆盖:
-
removeAll
在类JLayeredPane
- 自版本:
- 1.6
- 参见:
-
setComponentZOrder
将指定的组件移动到容器中指定的Z顺序索引。Z顺序确定组件绘制的顺序;具有最高Z顺序的组件首先绘制,具有最低Z顺序的组件最后绘制。在组件重叠时,具有较低Z顺序的组件会覆盖具有较高Z顺序的组件。如果组件是其他容器的子级,则在将其添加到此容器之前,将其从该容器中移除。此方法与
java.awt.Container.add(Component, int)
之间的重要区别在于,此方法在从其先前容器中移除组件时,除非必要且允许底层本机窗口系统,否则不会调用removeNotify
。这样,如果组件具有键盘焦点,则在移动到新位置时会保持焦点。此属性仅保证适用于轻量级非
Container
组件。此方法更改与布局相关的信息,因此会使组件层次结构无效。
注意:并非所有平台都支持从一个容器中的重量级组件更改Z顺序到另一个容器,而无需调用
removeNotify
。无法检测平台是否支持此功能,因此开发人员不应做任何假设。- 覆盖:
-
setComponentZOrder
在类Container
- 参数:
-
comp
- 要移动的组件 -
index
- 要插入组件的容器列表中的位置,其中getComponentCount()
追加到末尾 - 自版本:
- 1.6
- 参见:
-
paramString
返回此JDesktopPane
的字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能因实现而异。返回的字符串可能为空,但不能为null
。- 覆盖:
-
paramString
在类JLayeredPane
- 返回值:
-
此
JDesktopPane
的字符串表示形式
-
getAccessibleContext
获取与此JDesktopPane
关联的AccessibleContext
。对于桌面窗格,AccessibleContext
采用AccessibleJDesktopPane
的形式。如果需要,将创建一个新的AccessibleJDesktopPane
实例。- 指定者:
-
getAccessibleContext
在接口Accessible
- 覆盖:
-
getAccessibleContext
在类JLayeredPane
- 返回值:
-
作为此
JDesktopPane
的AccessibleContext
的AccessibleJDesktopPane
-