com.zfqjava.swing
Class XTree

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTree
                          |
                          +--com.zfqjava.swing.XTree
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable

public class XTree
extends javax.swing.JTree
implements javax.accessibility.Accessible

XTree provides a JTree expends component, provides inheritance selection mode.
Note:
Since XTree is compitable with JTree at API level, use it just replace JTree with XTree.

Since:
JDirChooser 1.2
See Also:
Serialized Form

Inner Class Summary
protected  class XTree.AccessibleXTree
          This class implements accessibility support for the XTree class.
 
Inner 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
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static int CONTIGUOUS_TREE_SELECTION
          Selection can only be contiguous.
static int DISCONTIGUOUS_TREE_SELECTION
          Selection can contain any number of items that are not necessarily contiguous.
static int INHERITANCE_TREE_SELECTION
          Selection can inherited from parent node.
static int SINGLE_TREE_SELECTION
          Selection can only contain one path at a time.
 
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
XTree()
          Returns a XTree with a sample model.
XTree(java.util.Hashtable value)
          Returns a XTree created from a Hashtable which does not display with root.
XTree(java.lang.Object[] value)
          Returns a XTree with each element of the specified array as the child of a new root node which is not displayed.
XTree(javax.swing.tree.TreeModel newModel)
          Returns an instance of XTree which displays the root node -- the tree is created using the specified data model.
XTree(javax.swing.tree.TreeNode root)
          Returns a XTree with the specified TreeNode as its root, which displays the root node.
XTree(javax.swing.tree.TreeNode root, boolean asksAllowsChildren)
          Returns a XTree with the specified TreeNode as its root, which displays the root node and which decides whether a node is a leaf node in the specified manner.
XTree(java.util.Vector value)
          Returns a XTree with each element of the specified Vector as the child of a new root node which is not displayed.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a ChangeListener to this cardpane.
 void clearSelection()
          Clears the selection.
protected  void fireStateChanged()
          Sends a ChangeEvent, whose source is this cardpane, to each listener.
protected  void fireValueChanged(javax.swing.event.TreeSelectionEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this XTree.
 javax.swing.event.ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added to this JCardpane with addChangeListener.
 javax.swing.tree.TreePath[] getSelection()
          Returns the paths of all selected values.
 int getSelectionMode()
          Returns the tree selection mode.
 boolean isSelectionEmpty()
          Returns true if the selection is currently empty.
protected  java.lang.String paramString()
          Returns a string representation of this XTree.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes a ChangeListener from this cardpane.
 void setRealCellEditor(javax.swing.tree.TreeCellEditor cellEditor)
          Sets the cell editor.
 void setRealCellRenderer(javax.swing.tree.TreeCellRenderer x)
          Sets the TreeCellRenderer that will be used to draw each cell.
 void setSelection(javax.swing.tree.TreePath[] paths)
          Selects the nodes identified by the specified array of paths.
 void setSelectionMode(int mode)
          Sets the tree selection mode.
 void updateUI()
           
 
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isVisible, makeVisible, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange
 
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, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SINGLE_TREE_SELECTION

public static final int SINGLE_TREE_SELECTION
Selection can only contain one path at a time.

CONTIGUOUS_TREE_SELECTION

public static final int CONTIGUOUS_TREE_SELECTION
Selection can only be contiguous. This will only be enforced if a RowMapper instance is provided. That is, if no RowMapper is set this behaves the same as DISCONTIGUOUS_TREE_SELECTION.

DISCONTIGUOUS_TREE_SELECTION

public static final int DISCONTIGUOUS_TREE_SELECTION
Selection can contain any number of items that are not necessarily contiguous.

INHERITANCE_TREE_SELECTION

public static final int INHERITANCE_TREE_SELECTION
Selection can inherited from parent node. Use JTree.getSelectionPaths() gets current selection.
Constructor Detail

XTree

public XTree()
Returns a XTree with a sample model. The default model used by the tree defines a leaf node as any node without children.
See Also:
DefaultTreeModel.asksAllowsChildren

XTree

public XTree(java.lang.Object[] value)
Returns a XTree with each element of the specified array as the child of a new root node which is not displayed. By default, the tree defines a leaf node as any node without children.
Parameters:
value - an array of Objects
See Also:
DefaultTreeModel.asksAllowsChildren

XTree

public XTree(java.util.Vector value)
Returns a XTree with each element of the specified Vector as the child of a new root node which is not displayed. By default, the tree defines a leaf node as any node without children.
Parameters:
value - a Vector
See Also:
DefaultTreeModel.asksAllowsChildren

XTree

public XTree(java.util.Hashtable value)
Returns a XTree created from a Hashtable which does not display with root. Each value-half of the key/value pairs in the HashTable becomes a child of the new root node. By default, the tree defines a leaf node as any node without children.
Parameters:
value - a Hashtable
See Also:
DefaultTreeModel.asksAllowsChildren

XTree

public XTree(javax.swing.tree.TreeNode root)
Returns a XTree with the specified TreeNode as its root, which displays the root node. By default, the tree defines a leaf node as any node without children.
Parameters:
root - a TreeNode object
See Also:
DefaultTreeModel.asksAllowsChildren

XTree

public XTree(javax.swing.tree.TreeNode root,
             boolean asksAllowsChildren)
Returns a XTree with the specified TreeNode as its root, which displays the root node and which decides whether a node is a leaf node in the specified manner.
Parameters:
root - a TreeNode object
asksAllowsChildren - if false, any node without children is a leaf node; if true, only nodes that do not allow children are leaf nodes
See Also:
DefaultTreeModel.asksAllowsChildren

XTree

public XTree(javax.swing.tree.TreeModel newModel)
Returns an instance of XTree which displays the root node -- the tree is created using the specified data model.
Parameters:
newModel - the TreeModel to use as the data model
Method Detail

setSelectionMode

public void setSelectionMode(int mode)
Sets the tree selection mode.
Parameters:
mode - the tree selection mdoe, one of 4 legal values:
  • XTree.SINGLE_TREE_SELECTION
  • XTree.CONTIGUOUS_TREE_SELECTION
  • XTree.DISCONTIGUOUS_TREE_SELECTION
  • XTree.INHERITANCE_TREE_SELECTION

getSelectionMode

public int getSelectionMode()
Returns the tree selection mode.
Returns:
the tree selection mode, one of 4 legal values:
  • XTree.SINGLE_TREE_SELECTION
  • XTree.CONTIGUOUS_TREE_SELECTION
  • XTree.DISCONTIGUOUS_TREE_SELECTION
  • XTree.INHERITANCE_TREE_SELECTION

clearSelection

public void clearSelection()
Clears the selection.
Overrides:
clearSelection in class javax.swing.JTree

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if the selection is currently empty.
Overrides:
isSelectionEmpty in class javax.swing.JTree
Returns:
true if the selection is currently empty

getSelection

public javax.swing.tree.TreePath[] getSelection()
Returns the paths of all selected values.
Returns:
an array of TreePath objects indicating the selected nodes, or null if nothing is currently selected

setSelection

public void setSelection(javax.swing.tree.TreePath[] paths)
Selects the nodes identified by the specified array of paths. If any component in any of the paths is hidden (under a collapsed node), and getExpandsSelectedPaths is true it is exposed (made viewable).
Parameters:
paths - an array of TreePath objects that specifies the nodes to select

updateUI

public void updateUI()
Overrides:
updateUI in class javax.swing.JTree

setRealCellRenderer

public void setRealCellRenderer(javax.swing.tree.TreeCellRenderer x)
Sets the TreeCellRenderer that will be used to draw each cell.
Parameters:
x - the TreeCellRenderer that is to render each cell

setRealCellEditor

public void setRealCellEditor(javax.swing.tree.TreeCellEditor cellEditor)
Sets the cell editor. A null value implies that the tree cannot be edited. If this represents a change in the cellEditor, the propertyChange method is invoked on all listeners.
Parameters:
cellEditor - the TreeCellEditor to use

fireValueChanged

protected void fireValueChanged(javax.swing.event.TreeSelectionEvent e)
Notifies all listeners that have registered interest for notification on this event type.
Overrides:
fireValueChanged in class javax.swing.JTree
Parameters:
e - the TreeSelectionEvent to be fired; generated by the TreeSelectionModel when a node is selected or deselected
See Also:
EventListenerList

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Adds a ChangeListener to this cardpane.
Parameters:
l - the ChangeListener to add
See Also:
fireStateChanged(), removeChangeListener(javax.swing.event.ChangeListener)

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener from this cardpane.
Parameters:
l - the ChangeListener to remove
See Also:
fireStateChanged(), addChangeListener(javax.swing.event.ChangeListener)

getChangeListeners

public javax.swing.event.ChangeListener[] getChangeListeners()
Returns an array of all the ChangeListeners added to this JCardpane with addChangeListener.
Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

protected void fireStateChanged()
Sends a ChangeEvent, whose source is this cardpane, to each listener. This method method is called each time a ChangeEvent is received from the model.
See Also:
addChangeListener(javax.swing.event.ChangeListener), EventListenerList

paramString

protected java.lang.String paramString()
Returns a string representation of this XTree. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
Overrides:
paramString in class javax.swing.JTree
Returns:
a string representation of this XTree.

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this XTree. For XTrees, the AccessibleContext takes the form of an AccessibleXTree. A new AccessibleXTree instance is created if necessary.
Specified by:
getAccessibleContext in interface javax.accessibility.Accessible
Overrides:
getAccessibleContext in class javax.swing.JTree
Returns:
an AccessibleXTree that serves as the AccessibleContext of this XTree


Copyright © 2001-2003 Extreme Component, Inc. All rights reserved.