ImageObserver, MenuContainer, Serializable, Accessible
@JavaBean(defaultProperty="UI") public class JDesktopPane extends JLayeredPane implements Accessible
JInternalFrame objects and add them to the JDesktopPane. JDesktopPane extends JLayeredPane to manage the potentially overlapping internal frames. It also maintains a reference to an instance of DesktopManager that is set by the UI class for the current look and feel (L&F). Note that JDesktopPane does not support borders.  This class is normally used as the parent of JInternalFrames to provide a pluggable DesktopManager object to the JInternalFrames. The installUI of the L&F specific implementation is responsible for setting the desktopManager variable appropriately. When the parent of a JInternalFrame is a JDesktopPane, it should delegate most of its behavior to the desktopManager (closing, resizing, etc). 
For further documentation and examples see How to Use Internal Frames, 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 XMLEncoder.
| Modifier and Type | Class | Description | 
|---|---|---|
| protected class  | JDesktopPane.AccessibleJDesktopPane | This class implements accessibility support for the  JDesktopPaneclass. | 
JLayeredPane.AccessibleJLayeredPane
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
| Modifier and Type | Field | Description | 
|---|---|---|
| static final int | LIVE_DRAG_MODE | Indicates that the entire contents of the item being dragged should appear inside the desktop pane. | 
| static final int | OUTLINE_DRAG_MODE | Indicates that an outline only of the item being dragged should appear inside the desktop pane. | 
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
| Constructor | Description | 
|---|---|
| JDesktopPane() | Creates a new  JDesktopPane. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| protected void | addImpl | Adds the specified component to this container at the specified index. | 
| AccessibleContext | getAccessibleContext() | Gets the  AccessibleContextassociated with thisJDesktopPane. | 
| JInternalFrame[] | getAllFrames() | Returns all  JInternalFramescurrently displayed in the desktop. | 
| JInternalFrame[] | getAllFramesInLayer | Returns all  JInternalFramescurrently displayed in the specified layer of the desktop. | 
| DesktopManager | getDesktopManager() | Returns the  DesktopMangerthat handles desktop-specific UI actions. | 
| int | getDragMode() | Gets the current "dragging style" used by the desktop pane. | 
| JInternalFrame | getSelectedFrame() | Returns the currently active  JInternalFramein thisJDesktopPane, ornullif noJInternalFrameis currently active. | 
| DesktopPaneUI | getUI() | Returns the L&F object that renders this component. | 
| String | getUIClassID() | Returns the name of the L&F class that renders this component. | 
| protected String | paramString() | Returns a string representation of this  JDesktopPane. | 
| void | remove | Remove the indexed component from this pane. | 
| void | removeAll() | Removes all the components from this container. | 
| JInternalFrame | selectFrame | Selects the next  JInternalFramein this desktop pane. | 
| void | setComponentZOrder | Moves the specified component to the specified z-order index in the container. | 
| void | setDesktopManager | Sets the  DesktopMangerthat will handle desktop-specific UI actions. | 
| void | setDragMode | Sets the "dragging style" used by the desktop pane. | 
| void | setSelectedFrame | Sets the currently active  JInternalFramein thisJDesktopPane. | 
| void | setUI | Sets the L&F object that renders this component. | 
| void | updateUI() | Notification from the  UIManagerthat the L&F has changed. | 
getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, putLayer, setLayer, setLayer, setPosition
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
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
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
public static final int LIVE_DRAG_MODE
public static final int OUTLINE_DRAG_MODE
public JDesktopPane()
JDesktopPane.public DesktopPaneUI getUI()
getUI in class JComponent
DesktopPaneUI object that renders this component@BeanProperty(hidden=true, visualUpdate=true, description="The UI object that implements the Component\'s LookAndFeel.") public void setUI(DesktopPaneUI ui)
ui - the DesktopPaneUI L&F object@BeanProperty(enumerationValues={"JDesktopPane.LIVE_DRAG_MODE","JDesktopPane.OUTLINE_DRAG_MODE"}, description="Dragging style for internal frame children.") public void setDragMode(int dragMode) dragMode - the style of drag to use for items in the Desktoppublic int getDragMode()
Live_DRAG_MODE or OUTLINE_DRAG_MODE
public DesktopManager getDesktopManager()
DesktopManger that handles desktop-specific UI actions.DesktopManger that handles desktop-specific UI actions@BeanProperty(description="Desktop manager to handle the internal frames in the desktop pane.") public void setDesktopManager(DesktopManager d)
DesktopManger that will handle desktop-specific UI actions. This may be overridden by LookAndFeel.d - the DesktopManager to usepublic void updateUI()
UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.updateUI in class JComponent
@BeanProperty(bound=false) public String getUIClassID()
getUIClassID in class JComponent
@BeanProperty(bound=false) public JInternalFrame[] getAllFrames()
JInternalFrames currently displayed in the desktop. Returns iconified frames as well as expanded frames.JInternalFrame objectspublic JInternalFrame getSelectedFrame()
JInternalFrame in this JDesktopPane, or null if no JInternalFrame is currently active.JInternalFrame or null
public void setSelectedFrame(JInternalFrame f)
JInternalFrame in this JDesktopPane. This method is used to bridge the package gap between JDesktopPane and the platform implementation code and should not be called directly. To visually select the frame the client must call JInternalFrame.setSelected(true) to activate the frame.f - the internal frame that's currently selectedpublic JInternalFrame[] getAllFramesInLayer(int layer)
JInternalFrames currently displayed in the specified layer of the desktop. Returns iconified frames as well expanded frames.layer - an int specifying the desktop layerJInternalFrame objectspublic JInternalFrame selectFrame(boolean forward)
JInternalFrame in this desktop pane.forward - a boolean indicating which direction to select in; true for forward, false for backwardnull if nothing was selectedprotected void addImpl(Component comp, Object constraints, int index)
addLayoutComponent method.  The constraints are defined by the particular layout manager being used. For example, the BorderLayout class defines five constraints: BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, and BorderLayout.CENTER. 
 The GridBagLayout class requires a GridBagConstraints object. Failure to pass the correct type of constraints object results in an IllegalArgumentException. 
 If the current layout manager implements LayoutManager2, then LayoutManager2.addLayoutComponent(Component,Object) is invoked on it. If the current layout manager does not implement LayoutManager2, and constraints is a String, then LayoutManager.addLayoutComponent(String,Component) is invoked on it. 
If the component is not an ancestor of this container and has a non-null parent, it is removed from its current parent before it is added to this container.
This is the method to override if a program needs to track every add request to a container as all other add methods defer to this one. An overriding method should usually include a call to the superclass's version of the method:
 super.addImpl(comp, constraints, index)  This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.
public void remove(int index)
remove in class JLayeredPane
index - an int specifying the component to removepublic void removeAll()
removeAll in class JLayeredPane
public void setComponentZOrder(Component comp, int index)
 If the component is a child of some other container, it is removed from that container before being added to this container. The important difference between this method and java.awt.Container.add(Component, int) is that this method doesn't call removeNotify on the component while removing it from its previous container unless necessary and when allowed by the underlying native windowing system. This way, if the component has the keyboard focus, it maintains the focus when moved to the new position. 
 This property is guaranteed to apply only to lightweight non-Container components. 
This method changes layout-related information, and therefore, invalidates the component hierarchy.
 Note: Not all platforms support changing the z-order of heavyweight components from one container into another without the call to removeNotify. There is no way to detect whether a platform supports this, so developers shouldn't make any assumptions.
setComponentZOrder in class Container
comp - the component to be movedindex - the position in the container's list to insert the component, where getComponentCount() appends to the endprotected String paramString()
JDesktopPane. 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.paramString in class JLayeredPane
JDesktopPane
@BeanProperty(bound=false) public AccessibleContext getAccessibleContext()
AccessibleContext associated with this JDesktopPane. For desktop panes, the AccessibleContext takes the form of an AccessibleJDesktopPane. A new AccessibleJDesktopPane instance is created if necessary.getAccessibleContext in interface Accessible
getAccessibleContext in class JLayeredPane
AccessibleJDesktopPane that serves as the AccessibleContext of this JDesktopPane
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/java.desktop/javax/swing/JDesktopPane.html