public class Tree extends Container
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
Constructor and Description |
---|
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 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
|
protected Button |
createNodeComponent(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.
|
Object |
getSelectedItem()
Returns the currently selected item in the tree
|
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
|
static void |
setNodeIcon(Image nodeIcon)
Sets the icon for a tree node
|
addComponent, addComponent, addComponent, addComponent, applyRTL, contains, flushReplace, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getLayout, getLayoutHeight, getLayoutWidth, getScrollIncrement, invalidate, isScrollableX, isScrollableY, layoutContainer, paint, paintGlass, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setLayout, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout
addFocusListener, animate, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragInitiated, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getHeight, getLabelForComponent, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getScrollAnimationSpeed, getScrollDimension, getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getSideGap, getStyle, getUIID, getUnselectedStyle, getVisibleBounds, getWidth, getX, getY, handlesInput, hasFocus, initComponent, initCustomStyle, isBorderPainted, isDragActivated, isEnabled, isFocusable, isFocusPainted, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyPressed, keyReleased, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setBorderPainted, setDirtyRegion, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setLabelForComponent, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setRTL, setScrollAnimationSpeed, setScrollSize, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setStyle, setTactileTouch, setTensileDragEnabled, setUIID, setUnselectedStyle, setUnSelectedStyle, setVisible, setWidth, setX, setY, styleChanged, toString
public Tree(TreeModel model)
model
- represents the contents 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 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 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