com.sun.lwuit.tree
Class Tree
java.lang.Object
com.sun.lwuit.Component
com.sun.lwuit.Container
com.sun.lwuit.tree.Tree
- All Implemented Interfaces:
- Animation, StyleListener
public class Tree
- extends Container
The tree component allows constructing simple tree component hierechies that can be expaneded seamingly
with no limit. The tree is bound to a model that can provide data with free form depth such as file system
or similarly structured data.
To customize the look of the tree the component can be derived and component creation can be replaced.
Constructor Summary |
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 |
Method Summary |
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 java.lang.String |
childToDisplayLabel(java.lang.Object child)
Converts a tree child to a label, this method can be overriden for
simple rendering effects |
protected Button |
createNodeComponent(java.lang.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. |
TreeModel |
getModel()
Returns the tree model instance |
java.lang.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 |
java.lang.Class[] |
getPropertyTypes()
Matches the property names method (see that method for further details). |
java.lang.Object |
getPropertyValue(java.lang.String name)
Returns the current value of the property name, this method is used by the GUI builder |
java.lang.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 |
void |
setModel(TreeModel model)
Sets the tree model to a new value |
static void |
setNodeIcon(Image nodeIcon)
Sets the icon for a tree node |
java.lang.String |
setPropertyValue(java.lang.String name,
java.lang.Object value)
Sets a new value to the given property, returns an error message if failed
and null if successful. |
Methods inherited from class com.sun.lwuit.Container |
addComponent, addComponent, addComponent, addComponent, animateLayout, animateLayoutAndWait, applyRTL, contains, dragInitiated, drop, findFirstFocusable, flushReplace, getBottomGap, getComponentAt, getComponentAt, getComponentCount, getComponentIndex, getGridPosX, getGridPosY, getLayout, getLayoutHeight, getLayoutWidth, getLeadComponent, getLeadParent, getScrollIncrement, getSideGap, invalidate, isEnabled, isScrollableX, isScrollableY, keyPressed, keyReleased, layoutContainer, paint, paintBackground, paintGlass, paramString, pointerHover, pointerPressed, refreshTheme, removeAll, removeComponent, replace, replace, replaceAndWait, replaceAndWait, replaceAndWait, revalidate, scrollComponentToVisible, setCellRenderer, setEnabled, setLayout, setLeadComponent, setScrollable, setScrollableX, setScrollableY, setScrollIncrement, setShouldCalcPreferredSize, setShouldLayout |
Methods inherited from class com.sun.lwuit.Component |
addFocusListener, animate, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragEnter, dragExit, draggingOver, drawDraggedImage, fireClicked, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getDragImage, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollOpacityChangeSpeed, getScrollX, getScrollY, getSelectCommandText, getSelectedRect, getSelectedStyle, getStyle, getTensileLength, getUIID, getUnselectedStyle, getWidth, getVisibleBounds, getX, getY, growShrink, handlesInput, hasFocus, initComponent, initCustomStyle, installDefaultPainter, isAlwaysTensile, isDragActivated, isDragAndDropOperation, isDraggable, isDropTarget, isFlatten, isFocusable, isGrabsPointerEvents, isHideInPortrait, isInitialized, isRTL, isScrollable, isScrollVisible, isSelectableInteraction, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, laidOut, longKeyPress, longPointerPress, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerDragged, pointerHoverPressed, pointerHoverReleased, pointerPressed, pointerReleased, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlwaysTensile, setDirtyRegion, setDisabledStyle, setDraggable, setDropTarget, setFlatten, setFocus, setFocusable, setGrabsPointerEvents, setHandlesInput, setHeight, setHideInPortrait, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setRTL, setScrollAnimationSpeed, setScrollOpacityChangeSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setTactileTouch, setTensileDragEnabled, setTensileLength, setUIID, setUnselectedStyle, setWidth, setVisible, setX, setY, styleChanged, toString |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Tree
public Tree()
- Constructor for usage by GUI builder and automated tools, normally one
should use the version that accepts the model
Tree
public Tree(TreeModel model)
- Construct a tree with the given tree model
- Parameters:
model
- represents the contents of the tree
getPropertyNames
public java.lang.String[] getPropertyNames()
- Description copied from class:
Component
- 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
- Overrides:
getPropertyNames
in class Component
- Returns:
- the property names allowing mutation
getPropertyTypes
public java.lang.Class[] getPropertyTypes()
- Description copied from class:
Component
- Matches the property names method (see that method for further details).
- Overrides:
getPropertyTypes
in class Component
- Returns:
- the types of the properties
getPropertyValue
public java.lang.Object getPropertyValue(java.lang.String name)
- Description copied from class:
Component
- Returns the current value of the property name, this method is used by the GUI builder
- Overrides:
getPropertyValue
in class Component
- Parameters:
name
- the name of the property
- Returns:
- the value of said property
setPropertyValue
public java.lang.String setPropertyValue(java.lang.String name,
java.lang.Object value)
- Description copied from class:
Component
- Sets a new value to the given property, returns an error message if failed
and null if successful. Notice that some builtin properties such as "$designMode" might be sent
to components to indicate application state.
- Overrides:
setPropertyValue
in class Component
- Parameters:
name
- the name of the propertyvalue
- new value for the property
- Returns:
- error message or null
getModel
public TreeModel getModel()
- Returns the tree model instance
- Returns:
- the tree model
setModel
public void setModel(TreeModel model)
- Sets the tree model to a new value
- Parameters:
model
- the model of the tree
setFolderIcon
public static void setFolderIcon(Image folderIcon)
- Sets the icon for a tree folder
- Parameters:
folderIcon
- the icon for a folder within the tree
setFolderOpenIcon
public static void setFolderOpenIcon(Image folderIcon)
- Sets the icon for a tree folder in its expanded state
- Parameters:
folderIcon
- the icon for a folder within the tree
setNodeIcon
public static void setNodeIcon(Image nodeIcon)
- Sets the icon for a tree node
- Parameters:
nodeIcon
- the icon for a node within the tree
getSelectedItem
public java.lang.Object getSelectedItem()
- Returns the currently selected item in the tree
- Returns:
- the object selected within the tree
createNodeComponent
protected Button createNodeComponent(java.lang.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.
- Parameters:
node
- the node object from the model to display on the buttondepth
- the depth within the tree (normally represented by indenting the entry)
- Returns:
- a button representing the node within the tree
childToDisplayLabel
protected java.lang.String childToDisplayLabel(java.lang.Object child)
- Converts a tree child to a label, this method can be overriden for
simple rendering effects
- Returns:
- a string representing the given tree node
addLeafListener
public void addLeafListener(ActionListener l)
- A listener that fires when a leaf is clicked
- Parameters:
l
- listener to fire when the leaf is clicked
removeLeafListener
public void removeLeafListener(ActionListener l)
- Removes the listener that fires when a leaf is clicked
- Parameters:
l
- listener to remove
calcPreferredSize
protected Dimension calcPreferredSize()
- Description copied from class:
Component
- Calculates the preferred size based on component content. This method is
invoked lazily by getPreferred size.
- Overrides:
calcPreferredSize
in class Container
- Returns:
- the calculated preferred size based on component content