org.jhotdraw.contrib
Class MDIDesktopPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLayeredPane
                  extended by javax.swing.JDesktopPane
                      extended by org.jhotdraw.contrib.MDIDesktopPane
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, Desktop

public class MDIDesktopPane
extends javax.swing.JDesktopPane
implements Desktop

An extension of JDesktopPane that supports often used MDI functionality. This class also handles setting scroll bars for when windows move too far to the left or bottom, providing the MDIDesktopPane is in a ScrollPane. Note by dnoyeb: I dont know why the container does not fire frame close events when the frames are removed from the container with remove as opposed to simply closed with the "x". so if you say removeAll from container you wont be notified. No biggie.

Version:
<$CURRENT_VERSION$>
Author:
Wolfram Kaiser (adapted from an article in JavaWorld), C.L.Gilbert
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
 
Fields inherited from class javax.swing.JDesktopPane
LIVE_DRAG_MODE, OUTLINE_DRAG_MODE
 
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
TOOL_TIP_TEXT_KEY, 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 org.jhotdraw.contrib.Desktop
PRIMARY, SECONDARY, TERTIARY
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MDIDesktopPane(DrawApplication newDrawApplication)
           
 
Method Summary
 void addDesktopListener(DesktopListener dpl)
           
 void addToDesktop(DrawingView dv, int location)
          This must match the signature of the superclass it is overriding or the method invocation may not resolve to this method unless it is called on a reference of specifically MDIDesktopPane type.
 void arrangeFramesHorizontally()
          Arranges the frames as efficiently as possibly with preference for keeping horizontal size maximal.
 void arrangeFramesVertically()
          Arranges the frames as efficiently as possibly with preference for keeping vertical size maximal.
 void cascadeFrames()
          Cascade all internal frames
 DrawingView getActiveDrawingView()
          For those absent minded components that were not paying attention to the listener events.
 DrawingView[] getAllFromDesktop(int location)
           
 void removeAllFromDesktop(int location)
           
 void removeDesktopListener(DesktopListener dpl)
           
 void removeFromDesktop(DrawingView dv, int location)
           
 void setAllSize(java.awt.Dimension d)
          Sets all component size properties ( maximum, minimum, preferred) to the given dimension.
 void setAllSize(int width, int height)
          Sets all component size properties ( maximum, minimum, preferred) to the given width and height.
 void tileFrames()
          Deprecated. use tileFramesHorizontally() instead
 void tileFramesHorizontally()
           
 void tileFramesVertically()
           
 void updateTitle(java.lang.String newDrawingTitle)
           
 
Methods inherited from class javax.swing.JDesktopPane
getAccessibleContext, getAllFrames, getAllFramesInLayer, getDesktopManager, getDragMode, getSelectedFrame, getUI, getUIClassID, isOpaque, setDesktopManager, setDragMode, setSelectedFrame, setUI, updateUI
 
Methods inherited from class javax.swing.JLayeredPane
getComponentCountInLayer, getComponentsInLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getPosition, highestLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, putLayer, remove, removeAll, setLayer, setLayer, setPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
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, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MDIDesktopPane

public MDIDesktopPane(DrawApplication newDrawApplication)
Method Detail

getActiveDrawingView

public DrawingView getActiveDrawingView()
Description copied from interface: Desktop
For those absent minded components that were not paying attention to the listener events.

Specified by:
getActiveDrawingView in interface Desktop

updateTitle

public void updateTitle(java.lang.String newDrawingTitle)
Specified by:
updateTitle in interface Desktop

addToDesktop

public void addToDesktop(DrawingView dv,
                         int location)
This must match the signature of the superclass it is overriding or the method invocation may not resolve to this method unless it is called on a reference of specifically MDIDesktopPane type. So this must be Component add(Component comp) in order to override its super class and Component add(JInternalFrame frame) will not properly override the super- class, but instead overload it. Note be sure to call this method and not add() when you want to add to the desktop. This allows complex desktops to be created. For instance, you can add split panes and scroll panes and such as normal with the add() method but then to get to the actual desktop you would still call this method.

Specified by:
addToDesktop in interface Desktop

removeFromDesktop

public void removeFromDesktop(DrawingView dv,
                              int location)
Specified by:
removeFromDesktop in interface Desktop

removeAllFromDesktop

public void removeAllFromDesktop(int location)
Specified by:
removeAllFromDesktop in interface Desktop

getAllFromDesktop

public DrawingView[] getAllFromDesktop(int location)
Specified by:
getAllFromDesktop in interface Desktop

addDesktopListener

public void addDesktopListener(DesktopListener dpl)
Specified by:
addDesktopListener in interface Desktop

removeDesktopListener

public void removeDesktopListener(DesktopListener dpl)
Specified by:
removeDesktopListener in interface Desktop

cascadeFrames

public void cascadeFrames()
Cascade all internal frames


tileFrames

public void tileFrames()
Deprecated. use tileFramesHorizontally() instead

Tile all internal frames


tileFramesHorizontally

public void tileFramesHorizontally()

tileFramesVertically

public void tileFramesVertically()

arrangeFramesVertically

public void arrangeFramesVertically()
Arranges the frames as efficiently as possibly with preference for keeping vertical size maximal.


arrangeFramesHorizontally

public void arrangeFramesHorizontally()
Arranges the frames as efficiently as possibly with preference for keeping horizontal size maximal.


setAllSize

public void setAllSize(java.awt.Dimension d)
Sets all component size properties ( maximum, minimum, preferred) to the given dimension.


setAllSize

public void setAllSize(int width,
                       int height)
Sets all component size properties ( maximum, minimum, preferred) to the given width and height.