javax.swing
Class DefaultDesktopManager

java.lang.Object
  |
  +--javax.swing.DefaultDesktopManager
All Implemented Interfaces:
DesktopManager, Serializable

public class DefaultDesktopManager
extends Object
implements DesktopManager, Serializable

Unsafe: 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.

Version:
1.46 04/15/02
Author:
David Kloba, Steve Wilson
See Also:
JDesktopPane, JInternalFrame, Serialized Form

Field Summary
private  Rectangle currentBounds
           
private  Point currentLoc
           
(package private) static int DEFAULT_DRAG_MODE
           
private  Rectangle desktopBounds
           
private  Graphics desktopGraphics
           
(package private)  int dragMode
           
(package private) static int FASTER_DRAG_MODE
           
private  Rectangle[] floatingItems
           
(package private) static String HAS_BEEN_ICONIFIED_PROPERTY
           
(package private) static int OUTLINE_DRAG_MODE
           
 
Constructor Summary
DefaultDesktopManager()
          Suppressed:
 
Method Summary
 void activateFrame(JInternalFrame f)
          Suppressed: This will activate f moving it to the front.
(package private)  void activateNextFrame(Container c)
           
 void beginDraggingFrame(JComponent f)
          Suppressed:
 void beginResizingFrame(JComponent f, int direction)
          Suppressed:
 void closeFrame(JInternalFrame f)
          Suppressed: Removes the frame, and, if necessary, the desktopIcon, from its parent.
 void deactivateFrame(JInternalFrame f)
          Suppressed:
 void deiconifyFrame(JInternalFrame f)
          Suppressed: Removes the desktopIcon from its parent and adds its frame to the parent.
 void dragFrame(JComponent f, int newX, int newY)
          Suppressed: 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(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.
 void endDraggingFrame(JComponent f)
          Suppressed:
 void endResizingFrame(JComponent f)
          Suppressed:
private  Rectangle[] findFloatingItems(JComponent f)
           
protected  Rectangle getBoundsForIconOf(JInternalFrame f)
          The iconifyFrame() code calls this to determine the proper bounds for the desktopIcon.
(package private)  JDesktopPane getDesktopPane(JComponent frame)
           
protected  Rectangle getPreviousBounds(JInternalFrame f)
          Gets the normal bounds of the component prior to the component being maximized.
 void iconifyFrame(JInternalFrame f)
          Suppressed: Removes the frame from its parent and adds its desktopIcon to the parent.
private  boolean isFloaterCollision(Rectangle moveFrom, Rectangle moveTo)
           
 void maximizeFrame(JInternalFrame f)
          Suppressed: Resizes the frame to fill its parents bounds.
 void minimizeFrame(JInternalFrame f)
          Suppressed: Restores the frame back to its size and position prior to a maximizeFrame call.
 void openFrame(JInternalFrame f)
          Suppressed: Normally this method will not be called.
protected  void removeIconFor(JInternalFrame f)
          Convenience method to remove the desktopIcon of f is necessary.
 void resizeFrame(JComponent f, int newX, int newY, int newWidth, int newHeight)
          Suppressed: Calls setBoundsForFrame with the new values.
 void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight)
          Suppressed: This moves the JComponent and repaints the damaged areas.
protected  void setPreviousBounds(JInternalFrame f, Rectangle r)
          Stores the bounds of the component just before a maximize call.
private  void setupDragMode(JComponent f)
           
protected  void setWasIcon(JInternalFrame f, Boolean value)
          Sets that the component has been iconized and the bounds of the desktopIcon are valid.
protected  boolean wasIcon(JInternalFrame f)
          Returns true if the component has been iconized and the bounds of the desktopIcon are valid, otherwise returns false.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HAS_BEEN_ICONIFIED_PROPERTY

static final String HAS_BEEN_ICONIFIED_PROPERTY

DEFAULT_DRAG_MODE

static final int DEFAULT_DRAG_MODE

OUTLINE_DRAG_MODE

static final int OUTLINE_DRAG_MODE

FASTER_DRAG_MODE

static final int FASTER_DRAG_MODE

dragMode

int dragMode

currentBounds

private transient Rectangle currentBounds

desktopGraphics

private transient Graphics desktopGraphics

desktopBounds

private transient Rectangle desktopBounds

floatingItems

private transient Rectangle[] floatingItems

currentLoc

private transient Point currentLoc
Constructor Detail

DefaultDesktopManager

public DefaultDesktopManager()
Suppressed:

Method Detail

openFrame

public void openFrame(JInternalFrame f)
Suppressed: Normally this method will not be called. If it is, it try to determine the appropriate parent from the desktopIcon of the frame. Will remove the desktopIcon from its parent if it successfully adds the frame.

Specified by:
openFrame in interface DesktopManager

closeFrame

public void closeFrame(JInternalFrame f)
Suppressed: Removes the frame, and, if necessary, the desktopIcon, from its parent.

Specified by:
closeFrame in interface DesktopManager
Parameters:
f - the JInternalFrame to be removed

maximizeFrame

public void maximizeFrame(JInternalFrame f)
Suppressed: Resizes the frame to fill its parents bounds.

Specified by:
maximizeFrame in interface DesktopManager

minimizeFrame

public void minimizeFrame(JInternalFrame f)
Suppressed: Restores the frame back to its size and position prior to a maximizeFrame call.

Specified by:
minimizeFrame in interface DesktopManager
Parameters:
f - the JInternalFrame to be restored

iconifyFrame

public void iconifyFrame(JInternalFrame f)
Suppressed: Removes the frame from its parent and adds its desktopIcon to the parent.

Specified by:
iconifyFrame in interface DesktopManager
Parameters:
f - the JInternalFrame to be iconified

activateNextFrame

void activateNextFrame(Container c)

deiconifyFrame

public void deiconifyFrame(JInternalFrame f)
Suppressed: Removes the desktopIcon from its parent and adds its frame to the parent.

Specified by:
deiconifyFrame in interface DesktopManager
Parameters:
f - the JInternalFrame to be de-iconified

activateFrame

public void activateFrame(JInternalFrame f)
Suppressed: 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.

Specified by:
activateFrame in interface DesktopManager
Parameters:
f - the JInternalFrame to be activated

deactivateFrame

public void deactivateFrame(JInternalFrame f)
Suppressed:

Specified by:
deactivateFrame in interface DesktopManager

beginDraggingFrame

public void beginDraggingFrame(JComponent f)
Suppressed:

Specified by:
beginDraggingFrame in interface DesktopManager

setupDragMode

private void setupDragMode(JComponent f)

dragFrame

public void dragFrame(JComponent f,
                      int newX,
                      int newY)
Suppressed: 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.

Specified by:
dragFrame in interface DesktopManager

endDraggingFrame

public void endDraggingFrame(JComponent f)
Suppressed:

Specified by:
endDraggingFrame in interface DesktopManager

beginResizingFrame

public void beginResizingFrame(JComponent f,
                               int direction)
Suppressed:

Specified by:
beginResizingFrame in interface DesktopManager

resizeFrame

public void resizeFrame(JComponent f,
                        int newX,
                        int newY,
                        int newWidth,
                        int newHeight)
Suppressed: Calls setBoundsForFrame with the new values.

Specified by:
resizeFrame in interface DesktopManager
Parameters:
f - the component to be resized
newX - the new x-coordinate
newY - the new y-coordinate
newWidth - the new width
newHeight - the new height

endResizingFrame

public void endResizingFrame(JComponent f)
Suppressed:

Specified by:
endResizingFrame in interface DesktopManager

setBoundsForFrame

public void setBoundsForFrame(JComponent f,
                              int newX,
                              int newY,
                              int newWidth,
                              int newHeight)
Suppressed: This moves the JComponent and repaints the damaged areas.

Specified by:
setBoundsForFrame in interface DesktopManager

removeIconFor

protected void removeIconFor(JInternalFrame f)
Convenience method to remove the desktopIcon of f is necessary.


getBoundsForIconOf

protected Rectangle getBoundsForIconOf(JInternalFrame f)
The iconifyFrame() code calls this to determine the proper bounds for the desktopIcon.


setPreviousBounds

protected void setPreviousBounds(JInternalFrame f,
                                 Rectangle r)
Stores the bounds of the component just before a maximize call.

Parameters:
f - the component about to be resized
r - the normal bounds to be saved away

getPreviousBounds

protected Rectangle getPreviousBounds(JInternalFrame f)
Gets the normal bounds of the component prior to the component being maximized.

Parameters:
f - the JInternalFrame of interest
Returns:
the normal bounds of the component

setWasIcon

protected void setWasIcon(JInternalFrame f,
                          Boolean value)
Sets that the component has been iconized and the bounds of the desktopIcon are valid.


wasIcon

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 - the JInternalFrame of interest
Returns:
true if the component has been iconized; otherwise returns false

getDesktopPane

JDesktopPane getDesktopPane(JComponent frame)

dragFrameFaster

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

isFloaterCollision

private boolean isFloaterCollision(Rectangle moveFrom,
                                   Rectangle moveTo)

findFloatingItems

private Rectangle[] findFloatingItems(JComponent f)

emergencyCleanup

private void emergencyCleanup(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



comments?