public class JXTree extends JTree
JXTree tree = new JXTree(new FileSystemModel());
// use system file icons and name to render
tree.setCellRenderer(new DefaultTreeRenderer(IconValues.FILE_ICON,
StringValues.FILE_NAME));
// highlight condition: file modified after a date
HighlightPredicate predicate = new HighlightPredicate() {
public boolean isHighlighted(Component renderer,
ComponentAdapter adapter) {
File file = getUserObject(adapter.getValue());
return file != null ? lastWeek < file.lastModified : false;
}
};
// highlight with foreground color
tree.addHighlighter(new ColorHighlighter(predicate, null, Color.RED);
Note: for full functionality, a DefaultTreeRenderer must be installed
as TreeCellRenderer. This is not done by default, because there are
unresolved issues when editing. PENDING JW: still? Check!
Note: to support the highlighting this implementation wraps the
TreeCellRenderer set by client code with a DelegatingRenderer which applies
the Highlighter after delegating the default configuration to the wrappee. As
a side-effect, getCellRenderer does return the wrapper instead of the custom
renderer. To access the latter, client code must call getWrappedCellRenderer.
JXTree tree = new JXTree();
tree.setRolloverEnabled(true);
tree.setCellRenderer(new DefaultTreeRenderer());
tree.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW,
null, Color.RED);
JXTree provides api to vend a renderer-controlled String representation of cell content. This allows the Searchable and Highlighters to use WYSIWYM (What-You-See-Is-What-You-Match), that is pattern matching against the actual string as seen by the user.
DefaultTreeRenderer
,
ComponentProvider
,
Highlighter
,
HighlightPredicate
,
SearchFactory
,
Searchable
,
Serialized FormModifier and Type | Class and Description |
---|---|
private class |
JXTree.Actions
A small class which dispatches actions.
|
class |
JXTree.CellEditorRemover
This class tracks changes in the keyboard focus state.
|
class |
JXTree.DelegatingRenderer
A decorator for the original TreeCellRenderer.
|
protected static class |
JXTree.TreeAdapter |
protected class |
JXTree.XTreeModelHandler
Listens to the model and updates the
expandedState accordingly
when nodes are removed, or changed. |
JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirector
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected CompoundHighlighter |
compoundHighlighter
Collection of active Highlighters.
|
protected ComponentAdapter |
dataAdapter |
private JXTree.DelegatingRenderer |
delegatingRenderer
Wrapper around the installed renderer, needed to support Highlighters.
|
private CellEditorListener |
editorListener
The CellEditorListener responsible to force the
focus back to the tree after terminating edits.
|
private JXTree.CellEditorRemover |
editorRemover
The propertyChangeListener responsible for terminating
edits if focus lost.
|
private static int[] |
EMPTY_INT_ARRAY
Empty int array used in getSelectedRows().
|
private static TreePath[] |
EMPTY_TREEPATH_ARRAY
Empty TreePath used in getSelectedPath() if selection empty.
|
private ChangeListener |
highlighterChangeListener
Listener to changes of Highlighters in collection.
|
private TreeRolloverController<JXTree> |
linkController
The RolloverController used if rollover is enabled.
|
private static Logger |
LOG |
private boolean |
overwriteIcons |
private RolloverProducer |
rolloverProducer
The RolloverProducer used if rollover is enabled.
|
private Searchable |
searchable |
private Color |
selectionBackground
Color of selected background.
|
private Color |
selectionForeground
Color of selected foreground.
|
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
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JXTree()
Constructs a
JXTree with a sample model. |
JXTree(Hashtable<?,?> value)
Constructs a
JXTree created from a Hashtable which does not
display with root. |
JXTree(Object[] value)
Constructs a
JXTree with each element of the specified array
as the child of a new root node which is not displayed. |
JXTree(TreeModel newModel)
Constructs an instance of
JXTree which displays the root
node -- the tree is created using the specified data model. |
JXTree(TreeNode root)
Constructs a
JXTree with the specified TreeNode as its root,
which displays the root node. |
JXTree(TreeNode root,
boolean asksAllowsChildren)
Constructs a
JXTree 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. |
JXTree(Vector<?> value)
Constructs a
JXTree with each element of the specified
Vector as the child of a new root node which is not displayed. |
Modifier and Type | Method and Description |
---|---|
void |
addHighlighter(Highlighter highlighter)
Appends a
Highlighter to the end of the list of used
Highlighter s. |
protected void |
analyseFocus()
This is called from cell editor listener if edit terminated.
|
void |
collapseAll()
Collapses all nodes in this tree.
|
protected TreeCellRenderer |
createDefaultCellRenderer()
Creates and returns the default cell renderer to use.
|
private Action |
createFindAction()
Creates and returns the action to invoke on a find request.
|
protected ChangeListener |
createHighlighterChangeListener()
Creates and returns the ChangeListener observing Highlighters.
|
protected TreeRolloverController<JXTree> |
createLinkController()
Creates and returns a RolloverController appropriate for this tree.
|
protected RolloverProducer |
createRolloverProducer()
Creates and returns the RolloverProducer to use with this tree.
|
protected TreeModelListener |
createTreeModelListener() |
protected void |
doFind()
Starts a search on this Tree's visible nodes.
|
void |
expandAll()
Expands all nodes in this tree.
|
private void |
expandRoot()
Expands the root path if a TreeModel has been set, does nothing if not.
|
TreeCellRenderer |
getCellRenderer()
Overridden to return the delegating renderer which is wrapped around the
original to support highlighting.
|
protected ComponentAdapter |
getComponentAdapter() |
protected ComponentAdapter |
getComponentAdapter(int index)
Convenience to access a configured ComponentAdapter.
|
protected CompoundHighlighter |
getCompoundHighlighter()
Returns the CompoundHighlighter assigned to the table, null if none.
|
private JXTree.DelegatingRenderer |
getDelegatingRenderer() |
protected ChangeListener |
getHighlighterChangeListener()
Returns the
ChangeListener to use with highlighters. |
Highlighter[] |
getHighlighters()
Returns the
Highlighter s used by this table. |
protected TreeRolloverController<JXTree> |
getLinkController()
Returns the RolloverController for this component.
|
TreePath |
getNextMatch(String prefix,
int startingRow,
Position.Bias bias)
Overridden to respect the string representation, if any.
|
Searchable |
getSearchable()
Returns a Searchable for this component, guaranteed to be not null.
|
Color |
getSelectionBackground()
Returns the background color for selected cells.
|
Color |
getSelectionForeground()
Returns the selection foreground color.
|
TreePath[] |
getSelectionPaths()
Overridden to always return a not-null array (following SwingX
convention).
|
int[] |
getSelectionRows()
Overridden to always return a not-null array (following SwingX
convention).
|
String |
getStringAt(int row)
Returns the string representation of the cell value at the given position.
|
String |
getStringAt(TreePath path)
Returns the string representation of the cell value at the given position.
|
TreeCellRenderer |
getWrappedCellRenderer()
Returns the renderer installed by client code or the default if none has
been set.
|
private void |
init()
Instantiates JXTree state which is new compared to super.
|
private void |
installSelectionColors()
Installs selection colors from UIManager.
|
void |
invalidateCellSizeCache()
Invalidates cell size caching in the ui delegate.
|
private boolean |
isFocusOwnerDescending()
Returns a boolean to indicate if the current focus owner
is descending from this table.
|
boolean |
isOverwriteRendererIcons()
Returns a boolean indicating whether the per-tree icons should be
copied to the renderer on setCellRenderer.
|
boolean |
isRolloverEnabled()
Returns a boolean indicating whether or not rollover support is enabled.
|
void |
removeHighlighter(Highlighter highlighter)
Removes the given Highlighter.
|
void |
removeNotify()
Overridden to release the CellEditorRemover, if any.
|
void |
setCellRenderer(TreeCellRenderer renderer)
Overridden to wrap the given renderer in a DelegatingRenderer to support
highlighting.
|
void |
setClosedIcon(Icon closedIcon)
Sets the Icon to use for a closed folder node.
|
void |
setCollapsedIcon(Icon collapsedIcon)
Sets the Icon to use for the handle of a collapsed node.
|
void |
setExpandedIcon(Icon expandedIcon)
Sets the Icon to use for the handle of an expanded node.
|
void |
setHighlighters(Highlighter... highlighters)
Sets the
Highlighter s to the table, replacing any old settings. |
void |
setLeafIcon(Icon leafIcon)
Sets the Icon to use for a leaf node.
|
void |
setModel(TreeModel newModel)
Overridden to initialize the String conversion method of the model, if any.
|
void |
setOpenIcon(Icon openIcon)
Sets the Icon to use for an open folder node.
|
void |
setOverwriteRendererIcons(boolean overwrite)
Property to control whether per-tree icons should be
copied to the renderer on setCellRenderer.
|
void |
setRolloverEnabled(boolean rolloverEnabled)
Sets the property to enable/disable rollover support.
|
void |
setSearchable(Searchable searchable)
Sets the Searchable for this component.
|
void |
setSelectionBackground(Color selectionBackground)
Sets the background color for selected cells.
|
void |
setSelectionForeground(Color selectionForeground)
Sets the foreground color for selected cells.
|
void |
startEditingAtPath(TreePath path)
Overridden to fix focus issues with editors.
|
private void |
uninstallSelectionColors()
Uninstalls selection colors.
|
private void |
updateEditorListener()
Hack to grab focus after editing.
|
private void |
updateEditorRemover()
Lazily creates and updates the internal CellEditorRemover.
|
protected void |
updateHighlighterUI()
Updates highlighter after
updateUI changes. |
protected void |
updateRendererEditorUI()
Quick fix for #1060-swingx: icons lost on toggling LAF
|
void |
updateUI()
Overridden to update selection background/foreground.
|
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, 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, 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, setDragEnabled, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, stopEditing, treeDidChange
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
private static final int[] EMPTY_INT_ARRAY
private static final TreePath[] EMPTY_TREEPATH_ARRAY
protected CompoundHighlighter compoundHighlighter
private ChangeListener highlighterChangeListener
private JXTree.DelegatingRenderer delegatingRenderer
private RolloverProducer rolloverProducer
private TreeRolloverController<JXTree> linkController
private boolean overwriteIcons
private Searchable searchable
private JXTree.CellEditorRemover editorRemover
private CellEditorListener editorListener
private Color selectionForeground
private Color selectionBackground
protected ComponentAdapter dataAdapter
public JXTree()
JXTree
with a sample model. The default model
used by this tree defines a leaf node as any node without children.public JXTree(Object[] value)
JXTree
with each element of the specified array
as the child of a new root node which is not displayed. By default, this
tree defines a leaf node as any node without children.
This version of the constructor simply invokes the super class version
with the same arguments.value
- an array of objects that are children of the root.public JXTree(Vector<?> value)
JXTree
with each element of the specified
Vector as the child of a new root node which is not displayed.
By default, this tree defines a leaf node as any node without children.
This version of the constructor simply invokes the super class version
with the same arguments.value
- an Vector of objects that are children of the root.public JXTree(Hashtable<?,?> value)
JXTree
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.
This version of the constructor simply invokes the super class version
with the same arguments.value
- a Hashtable containing objects that are children of the root.public JXTree(TreeNode root)
JXTree
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.
This version of the constructor simply invokes the super class version
with the same arguments.root
- root node of this treepublic JXTree(TreeNode root, boolean asksAllowsChildren)
JXTree
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.
This version of the constructor simply invokes the super class version
with the same arguments.root
- root node of this treeasksAllowsChildren
- if true, only nodes that do not allow children
are leaf nodes; otherwise, any node without children is a leaf node;DefaultTreeModel.asksAllowsChildren
public JXTree(TreeModel newModel)
JXTree
which displays the root
node -- the tree is created using the specified data model.
This version of the constructor simply invokes the super class version
with the same arguments.newModel
- the TreeModel
to use as the data modelprivate void init()
protected TreeModelListener createTreeModelListener()
createTreeModelListener
in class JTree
private Action createFindAction()
protected void doFind()
public Searchable getSearchable()
setSearchable(Searchable)
,
TreeSearchable
public void setSearchable(Searchable searchable)
searchable
- the Searchable to use for this component, may be null to
indicate using the default.getSearchable()
public String getStringAt(int row)
row
- the row index of the cell in view coordinatespublic String getStringAt(TreePath path)
path
- the TreePath representing the node.public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias)
PENDING JW: re-visit once we support deep node search.
getNextMatch
in class JTree
public void collapseAll()
public void expandAll()
Note: it's not recommended to use this method on the EDT for large/deep trees because expansion can take a considerable amount of time.
private void expandRoot()
public int[] getSelectionRows()
Overridden to always return a not-null array (following SwingX convention).
getSelectionRows
in class JTree
public TreePath[] getSelectionPaths()
Overridden to always return a not-null array (following SwingX convention).
getSelectionPaths
in class JTree
public Color getSelectionBackground()
Color
used for the background of
selected list itemssetSelectionBackground(java.awt.Color)
,
setSelectionForeground(java.awt.Color)
public Color getSelectionForeground()
Color
object for the foreground propertysetSelectionForeground(java.awt.Color)
,
setSelectionBackground(java.awt.Color)
public void setSelectionForeground(Color selectionForeground)
The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property.
selectionForeground
- the Color
to use in the foreground
for selected list itemsgetSelectionForeground()
,
setSelectionBackground(java.awt.Color)
,
JComponent.setForeground(java.awt.Color)
,
JComponent.setBackground(java.awt.Color)
,
JComponent.setFont(java.awt.Font)
public void setSelectionBackground(Color selectionBackground)
The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property.
selectionBackground
- the Color
to use for the
background of selected cellsgetSelectionBackground()
,
setSelectionForeground(java.awt.Color)
,
JComponent.setForeground(java.awt.Color)
,
JComponent.setBackground(java.awt.Color)
,
JComponent.setFont(java.awt.Font)
public void updateUI()
Overridden to update selection background/foreground. Mimicking behaviour of ui-delegates for JTable, JList.
protected void updateRendererEditorUI()
private void installSelectionColors()
Note: this should be done in the UI delegate.
private void uninstallSelectionColors()
Note: this should be done in the UI delegate.
protected void updateHighlighterUI()
updateUI
changes.UIDependent
public void setRolloverEnabled(boolean rolloverEnabled)
This can be enabled to show "live" rollover behaviour, f.i. the cursor over a cell rendered by a JXHyperlink.
The default value is false.
rolloverEnabled
- a boolean indicating whether or not the rollover
functionality should be enabled.isRolloverEnabled()
,
getLinkController()
,
createRolloverProducer()
,
RolloverRenderer
public boolean isRolloverEnabled()
setRolloverEnabled(boolean)
protected TreeRolloverController<JXTree> getLinkController()
PENDING JW: rename to getRolloverController
setRolloverEnabled(boolean)
,
createLinkController()
,
RolloverController
protected TreeRolloverController<JXTree> createLinkController()
getLinkController()
,
RolloverController
protected RolloverProducer createRolloverProducer()
RolloverProducer
to use with this treesetRolloverEnabled(boolean)
public void setHighlighters(Highlighter... highlighters)
Highlighter
s to the table, replacing any old settings.
None of the given Highlighters must be null.This is a bound property.
Note: as of version #1.257 the null constraint is enforced strictly. To remove all highlighters use this method without param.
highlighters
- zero or more not null highlighters to use for renderer decoration.NullPointerException
- if array is null or array contains null values.getHighlighters()
,
addHighlighter(Highlighter)
,
removeHighlighter(Highlighter)
public Highlighter[] getHighlighters()
Highlighter
s used by this table.
Maybe empty, but guarantees to be never null.setHighlighters(Highlighter[])
public void addHighlighter(Highlighter highlighter)
Highlighter
to the end of the list of used
Highlighter
s. The argument must not be null.
highlighter
- the Highlighter
to add, must not be null.NullPointerException
- if Highlighter
is null.removeHighlighter(Highlighter)
,
setHighlighters(Highlighter[])
public void removeHighlighter(Highlighter highlighter)
Does nothing if the Highlighter is not contained.
highlighter
- the Highlighter to remove.addHighlighter(Highlighter)
,
setHighlighters(Highlighter...)
protected CompoundHighlighter getCompoundHighlighter()
protected ChangeListener getHighlighterChangeListener()
ChangeListener
to use with highlighters. Lazily
creates the listener.not-null
protected ChangeListener createHighlighterChangeListener()
Here: repaints the table on receiving a stateChanged.
public void setExpandedIcon(Icon expandedIcon)
Note: this will only succeed if the current ui delegate is a BasicTreeUI otherwise it will do nothing.
PENDING JW: incomplete api (no getter) and not a bound property.
expandedIcon
- the Icon to use for the handle of an expanded node.public void setCollapsedIcon(Icon collapsedIcon)
collapsedIcon
- the Icon to use for the handle of a collapsed node.public void setLeafIcon(Icon leafIcon)
Note: this will only succeed if current renderer is a DefaultTreeCellRenderer.
PENDING JW: this (all setXXIcon) is old api pulled up from the JXTreeTable. Need to review if we really want it - problematic if sharing the same renderer instance across different trees. PENDING JW: incomplete api (no getter) and not a bound property.
leafIcon
- the Icon to use for a leaf node.public void setOpenIcon(Icon openIcon)
openIcon
- the Icon to use for an open folder node.public void setClosedIcon(Icon closedIcon)
closedIcon
- the Icon to use for a closed folder node.public void setOverwriteRendererIcons(boolean overwrite)
The default value is false. PENDING: should update the current renderer's icons when setting to true?
overwrite
- a boolean to indicate if the per-tree Icons should
be copied to the new renderer on setCellRenderer.isOverwriteRendererIcons()
,
setLeafIcon(Icon)
,
setOpenIcon(Icon)
,
setClosedIcon(Icon)
public boolean isOverwriteRendererIcons()
setOverwriteRendererIcons(boolean)
,
setLeafIcon(Icon)
,
setOpenIcon(Icon)
,
setClosedIcon(Icon)
private JXTree.DelegatingRenderer getDelegatingRenderer()
protected TreeCellRenderer createDefaultCellRenderer()
This implementation returns a renderer of type
DefaultTreeCellRenderer
. Note: Will be changed to
return a renderer of type DefaultTreeRenderer
,
once WrappingProvider is reasonably stable.
public TreeCellRenderer getCellRenderer()
Overridden to return the delegating renderer which is wrapped around the original to support highlighting. The returned renderer is of type DelegatingRenderer and guaranteed to not-null
getCellRenderer
in class JTree
setCellRenderer(TreeCellRenderer)
,
JXTree.DelegatingRenderer
public TreeCellRenderer getWrappedCellRenderer()
setCellRenderer(TreeCellRenderer)
public void setCellRenderer(TreeCellRenderer renderer)
Overridden to wrap the given renderer in a DelegatingRenderer to support highlighting.
Note: the wrapping implies that the renderer returned from the getCellRenderer
is not the renderer as given here, but the wrapper. To access the original,
use getWrappedCellRenderer
.
setCellRenderer
in class JTree
getWrappedCellRenderer()
,
getCellRenderer()
public void invalidateCellSizeCache()
This implementation calls BasicTreeUI setLeftChildIndent with the old indent if available. Beware: clearing the cache is an undocumented implementation side-effect of the method. Revisit if we ever should have a custom ui delegate.
public void startEditingAtPath(TreePath path)
Overridden to fix focus issues with editors. This method installs and updates the internal CellEditorRemover which terminates ongoing edits if appropriate. Additionally, it registers a CellEditorListener with the cell editor to grab the focus back to tree, if appropriate.
startEditingAtPath
in class JTree
updateEditorRemover()
private void updateEditorListener()
protected void analyseFocus()
private boolean isFocusOwnerDescending()
PENDING: copied from JXTable ... should be somewhere in a utility class?
public void removeNotify()
removeNotify
in class JComponent
private void updateEditorRemover()
public void setModel(TreeModel newModel)
Overridden to initialize the String conversion method of the model, if any.
PENDING JW: remove - that is an outdated approach?
protected ComponentAdapter getComponentAdapter()
protected ComponentAdapter getComponentAdapter(int index)
index
- the row index in view coordinates, must be valid.WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses