JavaTM 2 Platform
Std. Ed. v1.3

javax.swing
Class JDesktopPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JLayeredPane
                          |
                          +--javax.swing.JDesktopPane
All Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, Serializable

public class JDesktopPane
extends JLayeredPane
implements Accessible

A container used to create a multiple-document interface or a virtual desktop. You create 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).

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 the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JDesktopPane key assignments. For further documentation and examples see How to Use Internal Frames, 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. A future release of Swing will provide support for long term persistence.

See Also:
JInternalFrame, JInternalFrame.JDesktopIcon, DesktopManager, Serialized Form

Inner Class Summary
protected  class JDesktopPane.AccessibleJDesktopPane
          This class implements accessibility support for the JDesktopPane class.
 
Inner classes inherited from class javax.swing.JLayeredPane
JLayeredPane.AccessibleJLayeredPane
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent
 
Field Summary
static int LIVE_DRAG_MODE
          Used to indicate you wish to see the entire contents of the item being dragged inside the desktop pane.
static int OUTLINE_DRAG_MODE
          Used to indicate you wish to see only an outline of the item being dragged inside the desktop pane.
 
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JDesktopPane()
          Creates a new JDesktopPane.
 
Method Summary
 AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JDesktopPane.
 JInternalFrame[] getAllFrames()
          Returns all JInternalFrames currently displayed in the desktop.
 JInternalFrame[] getAllFramesInLayer(int layer)
          Returns all JInternalFrames currently displayed in the specified layer of the desktop.
 DesktopManager getDesktopManager()
          Returns the DesktopManger that handles desktop-specific UI actions.
 int getDragMode()
          Get the current "dragging style" used by the desktop pane.
 JInternalFrame getSelectedFrame()
          return the currently active JInternalFrame in this JDesktopPane, or null if no JInternalFrame is 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.
 boolean isOpaque()
          Returns true to indicate that this component paints every pixel in its range.
protected  String paramString()
          Returns a string representation of this JDesktopPane.
 void setDesktopManager(DesktopManager d)
          Sets the DesktopManger that will handle desktop-specific UI actions.
 void setDragMode(int dragMode)
          Set the "dragging style" used by the desktop pane.
 void setSelectedFrame(JInternalFrame f)
          set the currently active JInternalFrame in this JDesktopPane.
 void setUI(DesktopPaneUI ui)
          Sets the L&F object that renders this component.
 void updateUI()
          Notification from the UIManager that the L&F has changed.
 
Methods inherited from class javax.swing.JLayeredPane
addImpl, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, putLayer, remove, setLayer, setLayer, setPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LIVE_DRAG_MODE

public static int LIVE_DRAG_MODE
Used to indicate you wish to see the entire contents of the item being dragged inside the desktop pane.
See Also:
OUTLINE_DRAG_MODE, setDragMode(int)

OUTLINE_DRAG_MODE

public static int OUTLINE_DRAG_MODE
Used to indicate you wish to see only an outline of the item being dragged inside the desktop pane.
See Also:
LIVE_DRAG_MODE, setDragMode(int)
Constructor Detail

JDesktopPane

public JDesktopPane()
Creates a new JDesktopPane.
Method Detail

getUI

public DesktopPaneUI getUI()
Returns the L&F object that renders this component.
Returns:
the DesktopPaneUI object that renders this component

setUI

public void setUI(DesktopPaneUI ui)
Sets the L&F object that renders this component.
Parameters:
ui - the DesktopPaneUI L&F object
See Also:
UIDefaults.getUI(javax.swing.JComponent)

setDragMode

public void setDragMode(int dragMode)
Set the "dragging style" used by the desktop pane. You may want to change to one mode or another for performance or aesthetic reasons.
Parameters:
dragMode - the style of drag to use for items in the Desktop

getDragMode

public int getDragMode()
Get the current "dragging style" used by the desktop pane.
See Also:
setDragMode(int)

getDesktopManager

public DesktopManager getDesktopManager()
Returns the DesktopManger that handles desktop-specific UI actions.
Parameters:
d - the DesktopManager currently in use

setDesktopManager

public void setDesktopManager(DesktopManager d)
Sets the DesktopManger that will handle desktop-specific UI actions.
Parameters:
d - the DesktopManager to use

updateUI

public void updateUI()
Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
Overrides:
updateUI in class JComponent
See Also:
JComponent.updateUI()

getUIClassID

public String getUIClassID()
Returns the name of the L&F class that renders this component.
Overrides:
getUIClassID in class JComponent
Returns:
"DesktopPaneUI"
See Also:
JComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)

getAllFrames

public JInternalFrame[] getAllFrames()
Returns all JInternalFrames currently displayed in the desktop. Returns iconified frames as well as expanded frames.
Returns:
an array of JInternalFrame objects

getSelectedFrame

public JInternalFrame getSelectedFrame()
return the currently active JInternalFrame in this JDesktopPane, or null if no JInternalFrame is currently active.
Returns:
the currently active JInternalFrame or null
Since:
1.3

setSelectedFrame

public void setSelectedFrame(JInternalFrame f)
set the currently active JInternalFrame in this JDesktopPane.
Parameters:
f - The internal frame that's currently selected
Since:
1.3

getAllFramesInLayer

public JInternalFrame[] getAllFramesInLayer(int layer)
Returns all JInternalFrames currently displayed in the specified layer of the desktop. Returns iconified frames as well expanded frames.
Parameters:
layer - an int specifying the desktop layer
Returns:
an array of JInternalFrame objects
See Also:
JLayeredPane

isOpaque

public boolean isOpaque()
Returns true to indicate that this component paints every pixel in its range. (In other words, it does not have a transparent background or foreground.)
Overrides:
isOpaque in class JComponent
Returns:
true
See Also:
JComponent.isOpaque()

paramString

protected String paramString()
Returns a string representation of this 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.
Overrides:
paramString in class JLayeredPane
Returns:
a string representation of this JDesktopPane.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JDesktopPane. For desktop panes, the AccessibleContext takes the form of an AccessibleJDesktopPane. A new AccessibleJDesktopPane instance is created if necessary.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JLayeredPane
Returns:
an AccessibleJDesktopPane that serves as the AccessibleContext of this JDesktopPane

JavaTM 2 Platform
Std. Ed. v1.3

Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.