public class Tree extends Container
BASELINE, BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_POSSIBLE_DRAG_Y, LEFT, RIGHT, TOP
Constructor and Description |
---|
Tree()
Constructor for usage by GUI builder and automated tools, normally one
should use the version that accepts the model
|
Tree(TreeModel model)
Construct a tree with the given tree model
|
Modifier and Type | Method and Description |
---|---|
void |
addLeafListener(ActionListener l)
A listener that fires when a leaf is clicked
|
protected void |
bindNodeListener(ActionListener l,
Component node)
Since a node may be any component type developers should override this method to
add support for binding the click listener to the given component.
|
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content.
|
protected String |
childToDisplayLabel(Object child)
Converts a tree child to a label, this method can be overriden for
simple rendering effects
|
void |
collapsePath(Object... path)
Collapses the last element in the path
|
protected Component |
createNode(Object node,
int depth)
Creates a node within the tree, this method is protected allowing tree to be
subclassed to replace the rendering logic of individual tree buttons.
|
protected Button |
createNodeComponent(Object node,
int depth)
Deprecated.
replaced with createNode, bindNodeListener and setNodeIcon
|
void |
expandPath(Object... path)
Expands the tree path
|
TreeModel |
getModel()
Returns the tree model instance
|
String[] |
getPropertyNames()
A component may expose mutable property names for a UI designer to manipulate, this
API is designed for usage internally by the GUI builder code
|
String[] |
getPropertyTypeNames()
This method is here to workaround an XMLVM array type bug where property types aren't
identified properly, it returns the names of the types using the following type names:
String,int,double,long,byte,short,char,String[],String[][],byte[],Image,Image[],Object[],ListModel,ListCellRenderer
|
Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details).
|
Object |
getPropertyValue(String name)
Returns the current value of the property name, this method is used by the GUI builder
|
Object |
getSelectedItem()
Returns the currently selected item in the tree
|
boolean |
isMultilineMode()
Toggles a mode where rows in the tree can be broken since span buttons will
be used instead of plain buttons.
|
void |
removeLeafListener(ActionListener l)
Removes the listener that fires when a leaf is clicked
|
static void |
setFolderIcon(Image folderIcon)
Sets the icon for a tree folder
|
static void |
setFolderOpenIcon(Image folderIcon)
Sets the icon for a tree folder in its expanded state
|
void |
setModel(TreeModel model)
Sets the tree model to a new value
|
void |
setMultilineMode(boolean multilineMode)
Toggles a mode where rows in the tree can be broken since span buttons will
be used instead of plain buttons.
|
static void |
setNodeIcon(Image nodeIcon)
Sets the icon for a tree node
|
protected void |
setNodeIcon(Image icon,
Component node)
Sets the icon for the given node similar in scope to bindNodeListener
|
String |
setPropertyValue(String name,
Object value)
Sets a new value to the given property, returns an error message if failed
and null if successful.
|
addComponent, addComponent, addComponent, addComponent, animateHierarchy, animateHierarchyAndWait, animateHierarchyFade, animateHierarchyFadeAndWait, animateLayout, animateLayoutAndWait, animateLayoutFade, animateLayoutFadeAndWait, animateUnlayout, animateUnlayoutAndWait, applyRTL, cancelRepaints, clearClientProperties, contains, createAnimateMotion, dragInitiated, drop, findFirstFocusable, fireClicked, flushReplace, forceRevalidate, getBottomGap, getClosestComponentTo, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, getUIManager, initLaf, invalidate, isEnabled, isScrollableX, isScrollableY, isSelectableInteraction, keyPressed, keyReleased, layoutContainer, morph, morphAndWait, paint, paintComponentBackground, paintGlass, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout, setUIManager
addDragOverListener, addDropListener, addFocusListener, addPointerDraggedListener, addPointerPressedListener, addPointerReleasedListener, addPullToRefresh, addScrollListener, animate, bindProperty, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBindablePropertyNames, getBindablePropertyTypes, getBorder, getBoundPropertyValue, getBounds, getClientProperty, getCloudBoundProperty, getCloudDestinationProperty, getComponentForm, getComponentState, getDirtyRegion, getDisabledStyle, getDraggedx, getDraggedy, getDragImage, getDragRegionStatus, getDragSpeed, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getSameHeight, getSameWidth, getScrollable, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, growShrink, handlesInput, hasFocus, initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile, isCellRenderer, isDragActivated, isDragAndDropOperation, isDraggable, isDragRegion, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInClippingRegion, isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling, isSnapToGrid, isStickyDrag, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, onScrollX, onScrollY, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pinch, pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, refreshTheme, removeDragOverListener, removeDropListener, removeFocusListener, removePointerDraggedListener, removePointerPressedListener, removePointerReleasedListener, removeScrollListener, repaint, repaint, requestFocus, resetFocusable, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setBoundPropertyValue, setCloudBoundProperty, setCloudDestinationProperty, setComponentState, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL, setSameHeight, setSameWidth, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setVisible, setWidth, setX, setY, shouldBlockSideSwipe, styleChanged, toString, unbindProperty
public Tree()
public Tree(TreeModel model)
model
- represents the contents of the treepublic boolean isMultilineMode()
public void setMultilineMode(boolean multilineMode)
multilineMode
- the multilineMode to setpublic String[] getPropertyNames()
Component
getPropertyNames
in class Component
public Class[] getPropertyTypes()
Component
getPropertyTypes
in class Component
public String[] getPropertyTypeNames()
Component
getPropertyTypeNames
in class Component
public Object getPropertyValue(String name)
Component
getPropertyValue
in class Component
name
- the name of the propertypublic String setPropertyValue(String name, Object value)
Component
setPropertyValue
in class Component
name
- the name of the propertyvalue
- new value for the propertypublic TreeModel getModel()
public void setModel(TreeModel model)
model
- the model of the treepublic static void setFolderIcon(Image folderIcon)
folderIcon
- the icon for a folder within the treepublic static void setFolderOpenIcon(Image folderIcon)
folderIcon
- the icon for a folder within the treepublic static void setNodeIcon(Image nodeIcon)
nodeIcon
- the icon for a node within the treepublic void expandPath(Object... path)
path
- the path to expandpublic void collapsePath(Object... path)
path
- the path to the element that should be collapsedpublic Object getSelectedItem()
protected Button createNodeComponent(Object node, int depth)
node
- the node object from the model to display on the buttondepth
- the depth within the tree (normally represented by indenting the entry)protected void bindNodeListener(ActionListener l, Component node)
l
- listener interfacenode
- node component returned by createNodeprotected void setNodeIcon(Image icon, Component node)
icon
- the icon for the nodenode
- the node instanceprotected Component createNode(Object node, int depth)
node
- the node object from the model to display on the buttondepth
- the depth within the tree (normally represented by indenting the entry)protected String childToDisplayLabel(Object child)
public void addLeafListener(ActionListener l)
l
- listener to fire when the leaf is clickedpublic void removeLeafListener(ActionListener l)
l
- listener to removeprotected Dimension calcPreferredSize()
Component
calcPreferredSize
in class Container