javax.swing

Class DefaultDesktopManager

Implemented Interfaces:
DesktopManager, Serializable

public class DefaultDesktopManager
extends Object
implements DesktopManager, Serializable

The default implementation of DesktopManager for Swing. It implements the basic beaviours for JInternalFrames in arbitrary parents. The methods provided by the class are not meant to be called by the user, instead, the JInternalFrame methods will call these methods.
See Also:
Serialized Form

Constructor Summary

DefaultDesktopManager()
This creates a new DefaultDesktopManager object.

Method Summary

void
activateFrame(JInternalFrame frame)
This method activates the JInternalFrame by moving it to the front and selecting it.
void
beginDraggingFrame(JComponent component)
This method is called to indicate that the DesktopManager should prepare to drag the JInternalFrame.
void
beginResizingFrame(JComponent component, int direction)
This method is called to indicate that the given JComponent will be resized.
void
closeFrame(JInternalFrame frame)
This method removes the JInternalFrame and JDesktopIcon (if one is present) from their parents.
void
deactivateFrame(JInternalFrame frame)
This method is called when the JInternalFrame loses focus.
void
deiconifyFrame(JInternalFrame frame)
This method removes the JInternalFrame's JDesktopIcon representation and adds the JInternalFrame back to its parent.
void
dragFrame(JComponent component, int newX, int newY)
This method is called to drag the JInternalFrame to a new location.
void
endDraggingFrame(JComponent component)
This method indicates that the dragging is done.
void
endResizingFrame(JComponent component)
This method is called to indicate that the given JComponent has finished dragging.
protected Rectangle
getBoundsForIconOf(JInternalFrame frame)
This method is called by iconifyFrame to determine the bounds of the JDesktopIcon for the given JInternalFrame.
protected Rectangle
getPreviousBounds(JInternalFrame frame)
This method returns the normal bounds of the JInternalFrame from before the maximize call.
void
iconifyFrame(JInternalFrame frame)
This method removes the JInternalFrame from its parent and adds its JDesktopIcon representation.
void
maximizeFrame(JInternalFrame frame)
This method resizes the JInternalFrame to match its parent's bounds.
void
minimizeFrame(JInternalFrame frame)
This method restores the JInternalFrame's bounds to what they were previous to the setMaximize call.
void
openFrame(JInternalFrame frame)
This method is not normally called since the user will typically add the JInternalFrame to a Container.
protected void
removeIconFor(JInternalFrame frame)
This is a helper method that removes the JDesktopIcon of the given JInternalFrame from the parent.
void
resizeFrame(JComponent component, int newX, int newY, int newWidth, int newHeight)
This method resizes the give JComponent.
void
setBoundsForFrame(JComponent component, int newX, int newY, int newWidth, int newHeight)
This method calls setBounds with the given parameters and repaints the JComponent.
protected void
setPreviousBounds(JInternalFrame frame, Rectangle rect)
This method sets the bounds of the JInternalFrame right before the maximizeFrame call.
protected void
setWasIcon(JInternalFrame frame, Boolean value)
This method sets the value to true if the given JInternalFrame has been iconized and the bounds of its DesktopIcon are valid.
protected boolean
wasIcon(JInternalFrame frame)
This method returns true if the given JInternalFrame has been iconized and the bounds of its DesktopIcon are valid.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

DefaultDesktopManager

public DefaultDesktopManager()
This creates a new DefaultDesktopManager object.

Method Details

activateFrame

public void activateFrame(JInternalFrame frame)
This method activates the JInternalFrame by moving it to the front and selecting it.
Specified by:
activateFrame in interface DesktopManager
Parameters:
frame - The JInternalFrame to activate.

beginDraggingFrame

public void beginDraggingFrame(JComponent component)
This method is called to indicate that the DesktopManager should prepare to drag the JInternalFrame. Any state information needed to drag the frame will be prepared now.
Specified by:
beginDraggingFrame in interface DesktopManager
Parameters:
component - The JComponent to drag, usually a JInternalFrame.

beginResizingFrame

public void beginResizingFrame(JComponent component,
                               int direction)
This method is called to indicate that the given JComponent will be resized. Any state information necessary to resize the JComponent will be prepared now.
Specified by:
beginResizingFrame in interface DesktopManager
Parameters:
component - The JComponent to resize, usually a JInternalFrame.
direction - The direction to drag in (a SwingConstant).

closeFrame

public void closeFrame(JInternalFrame frame)
This method removes the JInternalFrame and JDesktopIcon (if one is present) from their parents.
Specified by:
closeFrame in interface DesktopManager
Parameters:
frame - The JInternalFrame to close.

deactivateFrame

public void deactivateFrame(JInternalFrame frame)
This method is called when the JInternalFrame loses focus.
Specified by:
deactivateFrame in interface DesktopManager
Parameters:
frame - The JInternalFram to deactivate.

deiconifyFrame

public void deiconifyFrame(JInternalFrame frame)
This method removes the JInternalFrame's JDesktopIcon representation and adds the JInternalFrame back to its parent.
Specified by:
deiconifyFrame in interface DesktopManager
Parameters:
frame - The JInternalFrame to deiconify.

dragFrame

public void dragFrame(JComponent component,
                      int newX,
                      int newY)
This method is called to drag the JInternalFrame to a new location.
Specified by:
dragFrame in interface DesktopManager
Parameters:
component - The JComponent to drag, usually a JInternalFrame.
newX - The new x coordinate.
newY - The new y coordinate.

endDraggingFrame

public void endDraggingFrame(JComponent component)
This method indicates that the dragging is done. Any state information stored by the DesktopManager can be cleared.
Specified by:
endDraggingFrame in interface DesktopManager
Parameters:
component - The JComponent that has finished dragging.

endResizingFrame

public void endResizingFrame(JComponent component)
This method is called to indicate that the given JComponent has finished dragging. Any state information stored by the DesktopManager can be cleared.
Specified by:
endResizingFrame in interface DesktopManager
Parameters:
component - The JComponent that finished resizing.

getBoundsForIconOf

protected Rectangle getBoundsForIconOf(JInternalFrame frame)
This method is called by iconifyFrame to determine the bounds of the JDesktopIcon for the given JInternalFrame.
Parameters:
frame - The JInternalFrame to find the bounds of its JDesktopIcon for.
Returns:
The bounds of the JDesktopIcon.

getPreviousBounds

protected Rectangle getPreviousBounds(JInternalFrame frame)
This method returns the normal bounds of the JInternalFrame from before the maximize call.
Parameters:
frame - The JInternalFrame that is being restored.
Returns:
The previous bounds of the JInternalFrame.

iconifyFrame

public void iconifyFrame(JInternalFrame frame)
This method removes the JInternalFrame from its parent and adds its JDesktopIcon representation.
Specified by:
iconifyFrame in interface DesktopManager
Parameters:
frame - The JInternalFrame to iconify.

maximizeFrame

public void maximizeFrame(JInternalFrame frame)
This method resizes the JInternalFrame to match its parent's bounds.
Specified by:
maximizeFrame in interface DesktopManager
Parameters:
frame - The JInternalFrame to maximize.

minimizeFrame

public void minimizeFrame(JInternalFrame frame)
This method restores the JInternalFrame's bounds to what they were previous to the setMaximize call.
Specified by:
minimizeFrame in interface DesktopManager
Parameters:
frame - The JInternalFrame to minimize.

openFrame

public void openFrame(JInternalFrame frame)
This method is not normally called since the user will typically add the JInternalFrame to a Container. If this is called, it will try to determine the parent of the JInternalFrame and remove any icon that represents this JInternalFrame and add this JInternalFrame.
Specified by:
openFrame in interface DesktopManager
Parameters:
frame - The JInternalFrame to open.

removeIconFor

protected void removeIconFor(JInternalFrame frame)
This is a helper method that removes the JDesktopIcon of the given JInternalFrame from the parent.
Parameters:
frame - The JInternalFrame to remove an icon for.

resizeFrame

public void resizeFrame(JComponent component,
                        int newX,
                        int newY,
                        int newWidth,
                        int newHeight)
This method resizes the give JComponent.
Specified by:
resizeFrame in interface DesktopManager
Parameters:
component - The JComponent to resize.
newX - The new x coordinate.
newY - The new y coordinate.
newWidth - The new width.
newHeight - The new height.

setBoundsForFrame

public void setBoundsForFrame(JComponent component,
                              int newX,
                              int newY,
                              int newWidth,
                              int newHeight)
This method calls setBounds with the given parameters and repaints the JComponent.
Specified by:
setBoundsForFrame in interface DesktopManager
Parameters:
component - The JComponent to set bounds for.
newX - The new x coordinate.
newY - The new y coordinate.
newWidth - The new width.
newHeight - The new height.

setPreviousBounds

protected void setPreviousBounds(JInternalFrame frame,
                                 Rectangle rect)
This method sets the bounds of the JInternalFrame right before the maximizeFrame call.
Parameters:
frame - The JInternalFrame being maximized.
rect - The normal bounds.

setWasIcon

protected void setWasIcon(JInternalFrame frame,
                          Boolean value)
This method sets the value to true if the given JInternalFrame has been iconized and the bounds of its DesktopIcon are valid.
Parameters:
frame - The JInternalFrame for the JDesktopIcon.
value - True if the JInternalFrame has been iconized and the bounds of the JDesktopIcon are valid.

wasIcon

protected boolean wasIcon(JInternalFrame frame)
This method returns true if the given JInternalFrame has been iconized and the bounds of its DesktopIcon are valid.
Parameters:
frame - The JInternalFrame for the JDesktopIcon.
Returns:
True if the given JInternalFrame has been iconized and the bounds of its DesktopIcon are valid.

DefaultDesktopManager.java -- Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.