Class TreeJDesktop

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JLayeredPane
                          |
                          +--javax.swing.JDesktopPane
                                |
                                +--TreeJDesktop
All Implemented Interfaces:
javax.accessibility.Accessible, javax.swing.event.ChangeListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, OptionListener, java.io.Serializable, TreeMessageListener

public class TreeJDesktop
extends javax.swing.JDesktopPane
implements OptionListener, TreeMessageListener, javax.swing.event.ChangeListener

The JDesktop class intended for a tree structure. Within this class, the panels for the trees are constructed as are the JPanel panes to hold them and the internal frames and tabbed pane.

The desktop listens for OptionEvents specific to a chosen tree, and calls that required command for the selected panel (whether it is tabbed pane or a selected window). Also, the desktop listens for events affecting all trees. The only events that bypass the desktop are those based upon clicking upon the tree.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JDesktopPane
javax.swing.JDesktopPane.AccessibleJDesktopPane
 
Nested classes inherited from class javax.swing.JLayeredPane
javax.swing.JLayeredPane.AccessibleJLayeredPane
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
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
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
TreeJDesktop()
          Sole Constructor, which constructs all of the tree panels and sets up all of the listening.
 
Method Summary
 void addMouseListener(java.awt.event.MouseListener l)
          Adds the specified mouse listener to receive mouse events from this component.
 void addMouseMotionListener(java.awt.event.MouseMotionListener l)
          Adds the specified mouse motion listener to receive mouse motion events from this component.
 void addOptionListener(OptionListener l)
          Adds an OptionEventListener according to the OptionEventListener interface and the OptionEvent.
 void addTreeMessageListener(TreeMessageListener l)
          Adds an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.
protected  void constructMessage()
          Constructs the message for the creating of a tree with random elements.
 javax.swing.Icon getIcon(java.lang.String imageName)
          Gets the icon from the resource (JAR file).
 javax.swing.JPanel getSelectedPanel()
          Gets the currently selected panel, whether it is the panel selected of the windows or whether it is the selected tabbed pane.
 void initialize()
          Original intialization.
 boolean isWindows()
          Gets if the desktop is set up in windows format or tabbed pabe format.
 void makeRandomTree(java.lang.String startKey, java.lang.String endKey, int size, boolean duplicates)
          Constructs a random Tree for every tree currently in the desktop.
 void makeTabbedPane()
          Makes a tabbedPane.
 void makeWindows()
          Makes the windows for the Desktop.
protected  void messageAction(java.lang.String msg, java.lang.Object msgObj)
          Calls all of the treeListeners of the Tree and passes the tree message information information regarding the status of the Tree.
protected  void optionEvent(OptionEvent e)
          Sends an optionEvent to all listeners of the current OptionEvents.
protected  void optionEvent(OptionEvent e, OptionListener l)
          Sends an optionEvent to all listeners of the current OptionEvents.
 void optionEventPerformed(OptionEvent e)
          Option event listener.
 void removeMouseListener(java.awt.event.MouseListener l)
          Removes the specified mouse listener so that it no longer receives mouse events from this component.
 void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
          Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component.
 void removeOptionListener(TreeMessageListener l)
          Removes an OptionEventListener according to the OptionEventListener interface and the OptionEvent.
 void removeTreeMessageListener(TreeMessageListener l)
          Removes an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.
 void setSelectedFrame(javax.swing.JInternalFrame f)
          Overides the desktop method, to add functionality, by passing information about the changed frame by tree message.
protected  void setWindows(boolean windows)
          Sets whether the desktop is set as windows or tabbed pane.
 void stateChanged(javax.swing.event.ChangeEvent e)
          Implements Change Listener.
 void treeMessageEventPerformed(TreeMessageEvent e)
          Listens to tree message events.
 
Methods inherited from class javax.swing.JDesktopPane
getAccessibleContext, getAllFrames, getAllFramesInLayer, getDesktopManager, getDragMode, getSelectedFrame, getUI, getUIClassID, isOpaque, paramString, setDesktopManager, setDragMode, setUI, updateUI
 
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, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseWheelListener, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeJDesktop

public TreeJDesktop()
Sole Constructor, which constructs all of the tree panels and sets up all of the listening.

Method Detail

initialize

public void initialize()
Original intialization. This calls methods that are called everytime a selected panel is changed, and obviously needs to be called initially.


makeWindows

public void makeWindows()
Makes the windows for the Desktop. The method also removes the JInternalFrames to make new frames or removes the tabbedPane (whichever is currently active).


makeTabbedPane

public void makeTabbedPane()
Makes a tabbedPane. It removes the Internal frames first and then constructs the internal frames.


isWindows

public boolean isWindows()
Gets if the desktop is set up in windows format or tabbed pabe format. If the desktop is as windows, true is returned.

Returns:
true if the desktop is set as windows.

getSelectedPanel

public javax.swing.JPanel getSelectedPanel()
Gets the currently selected panel, whether it is the panel selected of the windows or whether it is the selected tabbed pane.

Returns:
JPanel currently selected whether in the window or Tabbed Pane.

setWindows

protected void setWindows(boolean windows)
Sets whether the desktop is set as windows or tabbed pane. This should only be change along with actually changing the format or problems will insue.

Parameters:
windows - boolean true if the format is as windows.

addOptionListener

public void addOptionListener(OptionListener l)
Adds an OptionEventListener according to the OptionEventListener interface and the OptionEvent.

Parameters:
l - the listener added recieves the OptionEvents occuring.

removeOptionListener

public void removeOptionListener(TreeMessageListener l)
Removes an OptionEventListener according to the OptionEventListener interface and the OptionEvent.

Parameters:
l - the listener removed from recieving the OptionEvents occuring.

optionEvent

protected void optionEvent(OptionEvent e)
Sends an optionEvent to all listeners of the current OptionEvents. Simply passes the information on.

Parameters:
e - the option event to be passed on.

optionEvent

protected void optionEvent(OptionEvent e,
                           OptionListener l)
Sends an optionEvent to all listeners of the current OptionEvents. Simply passes the information on.

Parameters:
e - the option event to be passed on.
l - the specific optionListener to recieve the event.

addTreeMessageListener

public void addTreeMessageListener(TreeMessageListener l)
Adds an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.

Parameters:
l - the listener added recieves the TreeMessageEvents occuring.

removeTreeMessageListener

public void removeTreeMessageListener(TreeMessageListener l)
Removes an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.

Parameters:
l - the listener removed from recieving the TreeMessageEvents occuring.

messageAction

protected void messageAction(java.lang.String msg,
                             java.lang.Object msgObj)
Calls all of the treeListeners of the Tree and passes the tree message information information regarding the status of the Tree.


addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Adds the specified mouse listener to receive mouse events from this component. If l is null, no exception is thrown and no action is performed.

Overrides:
addMouseListener in class java.awt.Component
Parameters:
l - the mouse listener.

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener l)
Removes the specified mouse listener so that it no longer receives mouse events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If l is null, no exception is thrown and no action is performed.

Overrides:
removeMouseListener in class java.awt.Component
Parameters:
l - the mouse listener.

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
Adds the specified mouse motion listener to receive mouse motion events from this component. If l is null, no exception is thrown and no action is performed.

Overrides:
addMouseMotionListener in class java.awt.Component
Parameters:
l - the mouse motion listener.

removeMouseMotionListener

public void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this component. This method performs no function, nor does it throw an exception, if the listener specified by the argument was not previously added to this component. If l is null, no exception is thrown and no action is performed.

Overrides:
removeMouseMotionListener in class java.awt.Component
Parameters:
l - the mouse motion listener.

treeMessageEventPerformed

public void treeMessageEventPerformed(TreeMessageEvent e)
Listens to tree message events.

Specified by:
treeMessageEventPerformed in interface TreeMessageListener
Parameters:
e - TreeMessageEvent that contains information about the tree.

makeRandomTree

public void makeRandomTree(java.lang.String startKey,
                           java.lang.String endKey,
                           int size,
                           boolean duplicates)
Constructs a random Tree for every tree currently in the desktop.

Parameters:
startKey - the starting key for the random tree.
endKey - the ending key for the random tree.
size - the size of the random tree created.
duplicates - true if duplicates are allowed in the list.

constructMessage

protected void constructMessage()
Constructs the message for the creating of a tree with random elements. This is used so the last number entered appears in the fields unless the input type changes.


getIcon

public javax.swing.Icon getIcon(java.lang.String imageName)
Gets the icon from the resource (JAR file).


optionEventPerformed

public void optionEventPerformed(OptionEvent e)
Option event listener. The result of an optionEvent being performed depends upon the event. Within the desktop, the events are used or passed on to the trees accordingly. Here the separating of the events takes place.

Specified by:
optionEventPerformed in interface OptionListener
Parameters:
e - OptionEvent passed with information about the event.

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Implements Change Listener. On a state changed, messages are sent out according to the status of the new panel.

Specified by:
stateChanged in interface javax.swing.event.ChangeListener
Parameters:
e - ChangeEvent passed when the state changes.

setSelectedFrame

public void setSelectedFrame(javax.swing.JInternalFrame f)
Overides the desktop method, to add functionality, by passing information about the changed frame by tree message.

Overrides:
setSelectedFrame in class javax.swing.JDesktopPane
Parameters:
f - JInternalFrame that is selected.