Diamond Control Suite 3.0

diamondedge.swing
Class DsTree

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTree
                  extended by diamondedge.swing.DsTree
All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, Scrollable

public class DsTree
extends JTree
implements CellEditorListener, ItemSelectable

DsTree is a drop-in replacement for JTree. It displays a hierarchical list of DsTreeNode objects, each of which consists of a label and an optional icon. The class extends JTree with more formatting and styles on individual TreeNodes and sorting.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTree
JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirector
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static short CHILD
           
static int CLOSED_ICON
           
static short FIRST
           
protected  IconList iconlist
           
static short LAST
           
protected  DsTreeNode lastNodeEdited
           
static int LEAF_ICON
           
static short NEXT
           
static int OPENED_ICON
           
static short PREVIOUS
           
static int SELECTED_ICON
           
static int TOGGLE_ICON
           
static int TOGGLE_SEL_ICON
           
 
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
DsTree()
           
DsTree(DsTreeModel model)
           
DsTree(DsTreeNode root)
           
 
Method Summary
 void addItemListener(ItemListener l)
          Adds an ItemListener to monitor the state of the checkbox.
 void editingCanceled(ChangeEvent e)
          This tells the listeners the editor has canceled editing
 void editingStopped(ChangeEvent e)
          This tells the listeners the editor has ended editing
protected static DsTreeNode getDefaultTree()
          Creates and returns a sample tree of nodes.
 Icon getIcon(int i)
           
 IconList getIconList()
          Returns the IconList control to be used.
 DsTreeNode getNode(int index)
          Returns a specific DsTreeNode in the tree by position.
 DsTreeNode getNode(String key)
          Returns a specific DsTreeNode in the tree by key.
 DsTreeModel getNodes()
          Returns the model which is a collection of DsTreeNode objects.
 String getPathSeparator()
          Returns the delimiter string used for the path returned by the FullPath property.
 int getSelectedIndex()
          Returns the index to the currently selected node.
 DsTreeNode getSelectedNode()
          Returns the currently selected node.
 Object[] getSelectedObjects()
          Returns an array (length 1) containing the last ListItem edited or null.
 boolean isIconVisible()
          Returns a value that determines whether an icon is displayed next to each item in the tree.
 boolean isShowingCheckBoxes()
          Returns a value which determines if the control displays a checkbox next to each item in the tree.
 boolean isSorted()
          Indicates whether the children of this node are automatically sorted alphabetically.
 void removeItemListener(ItemListener l)
          Removes an ItemListener from the button.
 void setIcon(int i, Object icon)
           
 void setIconList(IconList i)
          Sets the IconList control to be used.
 void setIconVisible(boolean val)
          a value that determines whether an icon is displayed next to each item in the tree.
 void setModel(TreeModel newModel)
           
 void setSelectedIndex(int index)
          Sets the currently selected node by index.
 void setSelectedNode(DsTreeNode n)
          Sets the currently selected node.
 void setShowingCheckBoxes(boolean val)
          Sets a value which determines if the control displays a checkbox next to each item in the tree.
 void setSorted(boolean sort)
          Indicates whether the children of this node are automatically sorted alphabetically.
 void updateUI()
           
 
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, getDropLocation, getDropMode, 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, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, 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, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIRST

public static final short FIRST
See Also:
Constant Field Values

LAST

public static final short LAST
See Also:
Constant Field Values

NEXT

public static final short NEXT
See Also:
Constant Field Values

PREVIOUS

public static final short PREVIOUS
See Also:
Constant Field Values

CHILD

public static final short CHILD
See Also:
Constant Field Values

LEAF_ICON

public static final int LEAF_ICON
See Also:
Constant Field Values

OPENED_ICON

public static final int OPENED_ICON
See Also:
Constant Field Values

CLOSED_ICON

public static final int CLOSED_ICON
See Also:
Constant Field Values

SELECTED_ICON

public static final int SELECTED_ICON
See Also:
Constant Field Values

TOGGLE_ICON

public static final int TOGGLE_ICON
See Also:
Constant Field Values

TOGGLE_SEL_ICON

public static final int TOGGLE_SEL_ICON
See Also:
Constant Field Values

iconlist

protected IconList iconlist

lastNodeEdited

protected DsTreeNode lastNodeEdited
Constructor Detail

DsTree

public DsTree()

DsTree

public DsTree(DsTreeNode root)

DsTree

public DsTree(DsTreeModel model)
Method Detail

updateUI

public void updateUI()
Overrides:
updateUI in class JTree

getDefaultTree

protected static DsTreeNode getDefaultTree()
Creates and returns a sample tree of nodes. Used primarily for beanbuilders to show something interesting.

Returns:
the root DsTreeNode

getNodes

public DsTreeModel getNodes()
Returns the model which is a collection of DsTreeNode objects.


setModel

public void setModel(TreeModel newModel)
Overrides:
setModel in class JTree

getNode

public DsTreeNode getNode(String key)
Returns a specific DsTreeNode in the tree by key.


getNode

public DsTreeNode getNode(int index)
Returns a specific DsTreeNode in the tree by position.


getSelectedIndex

public int getSelectedIndex()
Returns the index to the currently selected node.


setSelectedIndex

public void setSelectedIndex(int index)
Sets the currently selected node by index.


getSelectedNode

public DsTreeNode getSelectedNode()
Returns the currently selected node.


setSelectedNode

public void setSelectedNode(DsTreeNode n)
Sets the currently selected node.


isSorted

public boolean isSorted()
Indicates whether the children of this node are automatically sorted alphabetically.


setSorted

public void setSorted(boolean sort)
Indicates whether the children of this node are automatically sorted alphabetically.


getPathSeparator

public String getPathSeparator()
Returns the delimiter string used for the path returned by the FullPath property.


getIconList

public IconList getIconList()
Returns the IconList control to be used.


setIconList

public void setIconList(IconList i)
Sets the IconList control to be used.


getIcon

public Icon getIcon(int i)

setIcon

public void setIcon(int i,
                    Object icon)

isIconVisible

public boolean isIconVisible()
Returns a value that determines whether an icon is displayed next to each item in the tree.


setIconVisible

public void setIconVisible(boolean val)
a value that determines whether an icon is displayed next to each item in the tree.


isShowingCheckBoxes

public boolean isShowingCheckBoxes()
Returns a value which determines if the control displays a checkbox next to each item in the tree.


setShowingCheckBoxes

public void setShowingCheckBoxes(boolean val)
Sets a value which determines if the control displays a checkbox next to each item in the tree.


editingCanceled

public void editingCanceled(ChangeEvent e)
This tells the listeners the editor has canceled editing

Specified by:
editingCanceled in interface CellEditorListener

editingStopped

public void editingStopped(ChangeEvent e)
This tells the listeners the editor has ended editing

Specified by:
editingStopped in interface CellEditorListener

addItemListener

public void addItemListener(ItemListener l)
Adds an ItemListener to monitor the state of the checkbox. An ItemEvent is sent to the listener when the state of the checkbox has changed.

Specified by:
addItemListener in interface ItemSelectable
Parameters:
l - the ItemListener to be added

removeItemListener

public void removeItemListener(ItemListener l)
Removes an ItemListener from the button.

Specified by:
removeItemListener in interface ItemSelectable
Parameters:
l - the ItemListener to be removed

getSelectedObjects

public Object[] getSelectedObjects()
Returns an array (length 1) containing the last ListItem edited or null.

Specified by:
getSelectedObjects in interface ItemSelectable
Returns:
an array containing 1 Object: the last ListItem edited, if the item was edited; otherwise null

Diamond Control Suite 3.0

Diamond Edge and Diamond Control Suite are trademarks or registered trademarks of Diamond Edge, Inc. Copyright 1999-2005 Diamond Edge, Inc. All Rights Reserved.