org.annotation.gui
Class DragAndDropTree

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTree
                  extended byorg.annotation.gui.JTree
                      extended byorg.annotation.gui.DragAndDropTree
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TreeSelectionListener

public class DragAndDropTree
extends JTree
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.event.TreeSelectionListener, java.awt.dnd.DragGestureListener, java.awt.dnd.DropTargetListener, java.awt.dnd.DragSourceListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JTree
javax.swing.JTree.AccessibleJTree, javax.swing.JTree.DynamicUtilTreeNode, javax.swing.JTree.EmptySelectionModel, javax.swing.JTree.TreeModelHandler, javax.swing.JTree.TreeSelectionRedirector
 
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
static int COPY
           
static int CUT
           
protected  javax.swing.tree.TreeNode DraggedNode
           
protected  javax.swing.tree.TreePath DraggedTreePath
           
protected  int JTreeTabSize
           
protected  javax.swing.tree.TreeNode SelectedNode
           
protected  javax.swing.tree.TreePath SelectedTreePath
          Stores the selected node info
 
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount
 
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
DragAndDropTree()
           
DragAndDropTree(java.awt.datatransfer.DataFlavor f)
           
DragAndDropTree(java.awt.datatransfer.DataFlavor f, javax.swing.tree.TreeModel m)
           
DragAndDropTree(javax.swing.tree.TreeModel m)
           
 
Method Summary
 void addDragAndDropTreeListener(DragAndDropTreeListener l)
           
 void centerPathInViewPort(javax.swing.tree.TreePath tp)
           
 void clearHighlights()
           
 void copy()
           
 void cut()
           
 void dragDropEnd(java.awt.dnd.DragSourceDropEvent dsde)
          DragSourceListener interface method
 void dragEnter(java.awt.dnd.DragSourceDragEvent dsde)
          DragSourceListener interface method
 void dragEnter(java.awt.dnd.DropTargetDragEvent e)
          DropTaregetListener interface method
 void dragExit(java.awt.dnd.DragSourceEvent dsde)
          DragSourceListener interface method
 void dragExit(java.awt.dnd.DropTargetEvent e)
          DropTaregetListener interface method
 void dragGestureRecognized(java.awt.dnd.DragGestureEvent e)
          DragGestureListener interface method
 void dragOver(java.awt.dnd.DragSourceDragEvent dsde)
          DragSourceListener interface method
 void dragOver(java.awt.dnd.DropTargetDragEvent e)
          DropTaregetListener interface method
 void drop(java.awt.dnd.DropTargetDropEvent e)
          DropTargetListener interface method - What we do when drag is released
 void dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
          DragSourceListener interface method
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
          DropTaregetListener interface method
 void enableDragAndDrop(boolean b)
           
 void expandAll(javax.swing.tree.TreePath tp)
           
 javax.swing.tree.TreeNode getDraggedNode()
           
 javax.swing.tree.TreeNode getSelectedNode()
          Returns The selected node
 java.lang.Object getUserObject(javax.swing.tree.TreePath tp)
           
 void highlightSubTree(javax.swing.tree.TreePath root)
           
 void highlightSubTree(javax.swing.tree.TreePath root, java.awt.Color c, java.lang.String n)
           
 void invalidate()
           
 boolean isPainting()
           
static void main(java.lang.String[] args)
           
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void moveDown()
           
 void moveUp()
           
 void paint(java.awt.Graphics g)
           
 void paste(int modifiers)
           
protected  void processKeyEvent(java.awt.event.KeyEvent e)
           
protected  void processMouseEvent(java.awt.event.MouseEvent e)
           
 void removeDragAndDropTreeListener(DragAndDropTreeListener l)
           
 void setKeysOff(boolean ko)
           
 void setPainting(boolean p)
           
 void treeNodesChanged(javax.swing.event.TreeModelEvent e)
           
 void treeNodesInserted(javax.swing.event.TreeModelEvent e)
           
 void treeNodesRemoved(javax.swing.event.TreeModelEvent e)
           
 void treeStructureChanged(javax.swing.event.TreeModelEvent e)
           
 void valueChanged(javax.swing.event.TreeSelectionEvent evt)
          TreeSelectionListener - sets selected node
 
Methods inherited from class org.annotation.gui.JTree
scrollRectToVisible
 
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, updateUI
 
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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, 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, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, 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, addMouseListener, addMouseMotionListener, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, 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
 

Field Detail

CUT

public static final int CUT
See Also:
Constant Field Values

COPY

public static final int COPY
See Also:
Constant Field Values

SelectedTreePath

protected javax.swing.tree.TreePath SelectedTreePath
Stores the selected node info


DraggedTreePath

protected javax.swing.tree.TreePath DraggedTreePath

SelectedNode

protected javax.swing.tree.TreeNode SelectedNode

DraggedNode

protected javax.swing.tree.TreeNode DraggedNode

JTreeTabSize

protected int JTreeTabSize
Constructor Detail

DragAndDropTree

public DragAndDropTree()

DragAndDropTree

public DragAndDropTree(javax.swing.tree.TreeModel m)

DragAndDropTree

public DragAndDropTree(java.awt.datatransfer.DataFlavor f)

DragAndDropTree

public DragAndDropTree(java.awt.datatransfer.DataFlavor f,
                       javax.swing.tree.TreeModel m)
Method Detail

setKeysOff

public void setKeysOff(boolean ko)

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent e)

expandAll

public void expandAll(javax.swing.tree.TreePath tp)

treeNodesChanged

public void treeNodesChanged(javax.swing.event.TreeModelEvent e)

treeNodesInserted

public void treeNodesInserted(javax.swing.event.TreeModelEvent e)

treeNodesRemoved

public void treeNodesRemoved(javax.swing.event.TreeModelEvent e)

treeStructureChanged

public void treeStructureChanged(javax.swing.event.TreeModelEvent e)

enableDragAndDrop

public void enableDragAndDrop(boolean b)

addDragAndDropTreeListener

public void addDragAndDropTreeListener(DragAndDropTreeListener l)

removeDragAndDropTreeListener

public void removeDragAndDropTreeListener(DragAndDropTreeListener l)

copy

public void copy()

cut

public void cut()

paste

public void paste(int modifiers)

moveDown

public void moveDown()

moveUp

public void moveUp()

getDraggedNode

public javax.swing.tree.TreeNode getDraggedNode()

getSelectedNode

public javax.swing.tree.TreeNode getSelectedNode()
Returns The selected node


dragGestureRecognized

public void dragGestureRecognized(java.awt.dnd.DragGestureEvent e)
DragGestureListener interface method

Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener

dragDropEnd

public void dragDropEnd(java.awt.dnd.DragSourceDropEvent dsde)
DragSourceListener interface method

Specified by:
dragDropEnd in interface java.awt.dnd.DragSourceListener

dragEnter

public void dragEnter(java.awt.dnd.DragSourceDragEvent dsde)
DragSourceListener interface method

Specified by:
dragEnter in interface java.awt.dnd.DragSourceListener

dragOver

public void dragOver(java.awt.dnd.DragSourceDragEvent dsde)
DragSourceListener interface method

Specified by:
dragOver in interface java.awt.dnd.DragSourceListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DragSourceDragEvent dsde)
DragSourceListener interface method

Specified by:
dropActionChanged in interface java.awt.dnd.DragSourceListener

dragExit

public void dragExit(java.awt.dnd.DragSourceEvent dsde)
DragSourceListener interface method

Specified by:
dragExit in interface java.awt.dnd.DragSourceListener

drop

public void drop(java.awt.dnd.DropTargetDropEvent e)
DropTargetListener interface method - What we do when drag is released

Specified by:
drop in interface java.awt.dnd.DropTargetListener

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent e)
DropTaregetListener interface method

Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent e)
DropTaregetListener interface method

Specified by:
dragExit in interface java.awt.dnd.DropTargetListener

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent e)
DropTaregetListener interface method

Specified by:
dragOver in interface java.awt.dnd.DropTargetListener

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
DropTaregetListener interface method

Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener

valueChanged

public void valueChanged(javax.swing.event.TreeSelectionEvent evt)
TreeSelectionListener - sets selected node

Specified by:
valueChanged in interface javax.swing.event.TreeSelectionListener

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

highlightSubTree

public void highlightSubTree(javax.swing.tree.TreePath root)

clearHighlights

public void clearHighlights()

highlightSubTree

public void highlightSubTree(javax.swing.tree.TreePath root,
                             java.awt.Color c,
                             java.lang.String n)

paint

public void paint(java.awt.Graphics g)

invalidate

public void invalidate()

setPainting

public void setPainting(boolean p)

isPainting

public boolean isPainting()

centerPathInViewPort

public void centerPathInViewPort(javax.swing.tree.TreePath tp)

main

public static final void main(java.lang.String[] args)

getUserObject

public java.lang.Object getUserObject(javax.swing.tree.TreePath tp)


Copyright © 2004 Thomas Morton and Jeremy LaCivita. All Rights Reserved.