APIdia Launch Partner
Top Description Fields Constructors Methods
javax.swing

public Class DefaultDesktopManager

extends Object
implements DesktopManager, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, javax.swing.DesktopManager
Known Direct Subclasses
javax.swing.plaf.basic.BasicDesktopPaneUI.BasicDesktopManager, javax.swing.plaf.synth.SynthDesktopPaneUI.SynthDesktopManager, com.sun.java.swing.plaf.motif.MotifDesktopPaneUI.MotifDesktopManager
Annotations
@SuppressWarnings:serial
Imports
java.awt.Color, .Component, .Container, .Dimension, .Graphics, .Point, .Rectangle, .Toolkit, .Window, java.beans.PropertyVetoException, sun.awt.AWTAccessor, .SunToolkit

This is an implementation of the DesktopManager. It currently implements the basic behaviors for managing JInternalFrames in an arbitrary parent. JInternalFrames that are not children of a JDesktop will use this component to handle their desktop-like actions.

This class provides a policy for the various JInternalFrame methods, it is not meant to be called directly rather the various JInternalFrame methods will call into the DesktopManager.

Authors
David Kloba, Steve Wilson
Since
1.2
See Also
JDesktopPane, JInternalFrame

Field Summary

Modifier and TypeField and Description
private transient Rectangle
private transient Point
pack-priv static final int
private transient Rectangle
private transient Graphics
private transient boolean
didDrag

Set to true when the user actually drags a frame vs clicks on it to start the drag operation.

pack-priv int
pack-priv static final int
private transient Rectangle[]
pack-priv static final String
pack-priv static final int

Constructor Summary

AccessConstructor and Description
public
DefaultDesktopManager()

Constructs a DefaultDesktopManager.

Method Summary

Modifier and TypeMethod and Description
public void
activateFrame(JInternalFrame
the JInternalFrame to be activated
f
)

Implements javax.swing.DesktopManager.activateFrame.

This will activate f moving it to the front.

public void
beginDraggingFrame(JComponent f)

Implements javax.swing.DesktopManager.beginDraggingFrame.

This method is normally called when the user has indicated that they will begin dragging a component around.

public void
beginResizingFrame(JComponent f, int direction)

Implements javax.swing.DesktopManager.beginResizingFrame.

This method is normally called when the user has indicated that they will begin resizing the frame.

public void
closeFrame(JInternalFrame
the JInternalFrame to be removed
f
)

Implements javax.swing.DesktopManager.closeFrame.

Removes the frame, and, if necessary, the desktopIcon, from its parent.

public void
deactivateFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.deactivateFrame.

Generally, indicate that this frame has lost focus.

public void
deiconifyFrame(JInternalFrame
the JInternalFrame to be de-iconified
f
)

Implements javax.swing.DesktopManager.deiconifyFrame.

Removes the desktopIcon from its parent and adds its frame to the parent.

public void
dragFrame(JComponent f, int newX, int newY)

Implements javax.swing.DesktopManager.dragFrame.

Moves the visible location of the frame being dragged to the location specified.

private void
dragFrameFaster(JComponent f, int newX, int newY)

private void
emergencyCleanup(final JComponent f)

This method is here to clean up problems associated with a race condition which can occur when the full contents of a copyArea's source argument is not available onscreen.

public void
endDraggingFrame(JComponent f)

Implements javax.swing.DesktopManager.endDraggingFrame.

This method signals the end of the dragging session.

public void
endResizingFrame(JComponent f)

Implements javax.swing.DesktopManager.endResizingFrame.

This method signals the end of the resize session.

private Rectangle[]
protected Rectangle

Returns:

a Rectangle containing bounds for the desktopIcon
getBoundsForIconOf
(JInternalFrame
the JInternalFrame of interest
f
)

The iconifyFrame() code calls this to determine the proper bounds for the desktopIcon.

pack-priv JDesktopPane
protected Rectangle

Returns:

the normal bounds of the component
getPreviousBounds
(JInternalFrame
the JInternalFrame of interest
f
)

Gets the normal bounds of the component prior to the component being maximized.

public void
iconifyFrame(JInternalFrame
the JInternalFrame to be iconified
f
)

Implements javax.swing.DesktopManager.iconifyFrame.

Removes the frame from its parent and adds its desktopIcon to the parent.

private boolean
public void
maximizeFrame(JInternalFrame
the frame to be resized
f
)

Implements javax.swing.DesktopManager.maximizeFrame.

Resizes the frame to fill its parents bounds.

public void
minimizeFrame(JInternalFrame
the JInternalFrame to be restored
f
)

Implements javax.swing.DesktopManager.minimizeFrame.

Restores the frame back to its size and position prior to a maximizeFrame call.

public void
openFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.openFrame.

Normally this method will not be called.

protected void
removeIconFor(JInternalFrame
the JInternalFrame for which to remove the desktopIcon
f
)

Convenience method to remove the desktopIcon of f is necessary.

public void
resizeFrame(JComponent
the component to be resized
f
,
int
the new x-coordinate
newX
,
int
the new y-coordinate
newY
,
int
the new width
newWidth
,
int
the new height
newHeight
)

Implements javax.swing.DesktopManager.resizeFrame.

Calls setBoundsForFrame with the new values.

public void
setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight)

Implements javax.swing.DesktopManager.setBoundsForFrame.

This moves the JComponent and repaints the damaged areas.

protected void
setPreviousBounds(JInternalFrame
the component about to be resized
f
,
Rectangle
the normal bounds to be saved away
r
)

Stores the bounds of the component just before a maximize call.

private void
protected void
setWasIcon(JInternalFrame
the JInternalFrame of interest
f
,
Boolean
a Boolean signifying if component has been iconized
value
)

Sets that the component has been iconized and the bounds of the desktopIcon are valid.

protected boolean

Returns:

true if the component has been iconized; otherwise returns false
wasIcon
(JInternalFrame
the JInternalFrame of interest
f
)

Returns true if the component has been iconized and the bounds of the desktopIcon are valid, otherwise returns false.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentBoundsback to summary
private transient Rectangle currentBounds
currentLocback to summary
private transient Point currentLoc
DEFAULT_DRAG_MODEback to summary
pack-priv static final int DEFAULT_DRAG_MODE
desktopBoundsback to summary
private transient Rectangle desktopBounds
desktopGraphicsback to summary
private transient Graphics desktopGraphics
didDragback to summary
private transient boolean didDrag

Set to true when the user actually drags a frame vs clicks on it to start the drag operation. This is only used when dragging with FASTER_DRAG_MODE.

dragModeback to summary
pack-priv int dragMode
FASTER_DRAG_MODEback to summary
pack-priv static final int FASTER_DRAG_MODE
floatingItemsback to summary
private transient Rectangle[] floatingItems
HAS_BEEN_ICONIFIED_PROPERTYback to summary
pack-priv static final String HAS_BEEN_ICONIFIED_PROPERTY
OUTLINE_DRAG_MODEback to summary
pack-priv static final int OUTLINE_DRAG_MODE

Constructor Detail

DefaultDesktopManagerback to summary
public DefaultDesktopManager()

Constructs a DefaultDesktopManager.

Method Detail

activateFrameback to summary
public void activateFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.activateFrame.

This will activate f moving it to the front. It will set the current active frame's (if any) IS_SELECTED_PROPERTY to false. There can be only one active frame across all Layers.

Parameters
f:JInternalFrame

the JInternalFrame to be activated

beginDraggingFrameback to summary
public void beginDraggingFrame(JComponent f)

Implements javax.swing.DesktopManager.beginDraggingFrame.

Doc from javax.swing.DesktopManager.beginDraggingFrame.

This method is normally called when the user has indicated that they will begin dragging a component around. This method should be called prior to any dragFrame() calls to allow the DesktopManager to prepare any necessary state. Normally f will be a JInternalFrame.

beginResizingFrameback to summary
public void beginResizingFrame(JComponent f, int direction)

Implements javax.swing.DesktopManager.beginResizingFrame.

Doc from javax.swing.DesktopManager.beginResizingFrame.

This method is normally called when the user has indicated that they will begin resizing the frame. This method should be called prior to any resizeFrame() calls to allow the DesktopManager to prepare any necessary state. Normally f will be a JInternalFrame.

closeFrameback to summary
public void closeFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.closeFrame.

Removes the frame, and, if necessary, the desktopIcon, from its parent.

Parameters
f:JInternalFrame

the JInternalFrame to be removed

deactivateFrameback to summary
public void deactivateFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.deactivateFrame.

Doc from javax.swing.DesktopManager.deactivateFrame.

Generally, indicate that this frame has lost focus. This is usually called after the JInternalFrame's IS_SELECTED_PROPERTY has been set to false.

deiconifyFrameback to summary
public void deiconifyFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.deiconifyFrame.

Removes the desktopIcon from its parent and adds its frame to the parent.

Parameters
f:JInternalFrame

the JInternalFrame to be de-iconified

dragFrameback to summary
public void dragFrame(JComponent f, int newX, int newY)

Implements javax.swing.DesktopManager.dragFrame.

Moves the visible location of the frame being dragged to the location specified. The means by which this occurs can vary depending on the dragging algorithm being used. The actual logical location of the frame might not change until endDraggingFrame is called.

dragFrameFasterback to summary
private void dragFrameFaster(JComponent f, int newX, int newY)
emergencyCleanupback to summary
private void emergencyCleanup(final JComponent f)

This method is here to clean up problems associated with a race condition which can occur when the full contents of a copyArea's source argument is not available onscreen. This uses brute force to clean up in case of possible damage

endDraggingFrameback to summary
public void endDraggingFrame(JComponent f)

Implements javax.swing.DesktopManager.endDraggingFrame.

Doc from javax.swing.DesktopManager.endDraggingFrame.

This method signals the end of the dragging session. Any state maintained by the DesktopManager can be removed here. Normally f will be a JInternalFrame.

endResizingFrameback to summary
public void endResizingFrame(JComponent f)

Implements javax.swing.DesktopManager.endResizingFrame.

Doc from javax.swing.DesktopManager.endResizingFrame.

This method signals the end of the resize session. Any state maintained by the DesktopManager can be removed here. Normally f will be a JInternalFrame.

findFloatingItemsback to summary
private Rectangle[] findFloatingItems(JComponent f)
getBoundsForIconOfback to summary
protected Rectangle getBoundsForIconOf(JInternalFrame f)

The iconifyFrame() code calls this to determine the proper bounds for the desktopIcon.

Parameters
f:JInternalFrame

the JInternalFrame of interest

Returns:Rectangle

a Rectangle containing bounds for the desktopIcon

getDesktopPaneback to summary
pack-priv JDesktopPane getDesktopPane(JComponent frame)
getPreviousBoundsback to summary
protected Rectangle getPreviousBounds(JInternalFrame f)

Gets the normal bounds of the component prior to the component being maximized.

Parameters
f:JInternalFrame

the JInternalFrame of interest

Returns:Rectangle

the normal bounds of the component

iconifyFrameback to summary
public void iconifyFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.iconifyFrame.

Removes the frame from its parent and adds its desktopIcon to the parent.

Parameters
f:JInternalFrame

the JInternalFrame to be iconified

isFloaterCollisionback to summary
private boolean isFloaterCollision(Rectangle moveFrom, Rectangle moveTo)
maximizeFrameback to summary
public void maximizeFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.maximizeFrame.

Resizes the frame to fill its parents bounds.

Parameters
f:JInternalFrame

the frame to be resized

minimizeFrameback to summary
public void minimizeFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.minimizeFrame.

Restores the frame back to its size and position prior to a maximizeFrame call.

Parameters
f:JInternalFrame

the JInternalFrame to be restored

openFrameback to summary
public void openFrame(JInternalFrame f)

Implements javax.swing.DesktopManager.openFrame.

Normally this method will not be called. If it is, it tries to determine the appropriate parent from the desktopIcon of the frame. Will remove the desktopIcon from its parent if it successfully adds the frame.

removeIconForback to summary
protected void removeIconFor(JInternalFrame f)

Convenience method to remove the desktopIcon of f is necessary.

Parameters
f:JInternalFrame

the JInternalFrame for which to remove the desktopIcon

resizeFrameback to summary
public void resizeFrame(JComponent f, int newX, int newY, int newWidth, int newHeight)

Implements javax.swing.DesktopManager.resizeFrame.

Calls setBoundsForFrame with the new values.

Parameters
f:JComponent

the component to be resized

newX:int

the new x-coordinate

newY:int

the new y-coordinate

newWidth:int

the new width

newHeight:int

the new height

setBoundsForFrameback to summary
public void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight)

Implements javax.swing.DesktopManager.setBoundsForFrame.

This moves the JComponent and repaints the damaged areas.

setPreviousBoundsback to summary
protected void setPreviousBounds(JInternalFrame f, Rectangle r)

Stores the bounds of the component just before a maximize call.

Parameters
f:JInternalFrame

the component about to be resized

r:Rectangle

the normal bounds to be saved away

setupDragModeback to summary
private void setupDragMode(JComponent f)
setWasIconback to summary
protected void setWasIcon(JInternalFrame f, Boolean value)

Sets that the component has been iconized and the bounds of the desktopIcon are valid.

Parameters
f:JInternalFrame

the JInternalFrame of interest

value:Boolean

a Boolean signifying if component has been iconized

wasIconback to summary
protected boolean wasIcon(JInternalFrame f)

Returns true if the component has been iconized and the bounds of the desktopIcon are valid, otherwise returns false.

Parameters
f:JInternalFrame

the JInternalFrame of interest

Returns:boolean

true if the component has been iconized; otherwise returns false