Class JXTree
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JTree
-
- org.jdesktop.swingx.JXTree
-
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable
@JavaBean public class JXTree extends javax.swing.JTreeEnhanced Tree component with support for SwingX rendering, highlighting, rollover and search functionality.Rendering and Highlighting
As all SwingX collection views, a JXTree is a HighlighterClient (PENDING JW: formally define and implement, like in AbstractTestHighlighter), that is it provides consistent api to add and remove Highlighters which can visually decorate the rendering component.
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(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);Rollover
As all SwingX collection views, a JXTree supports per-cell rollover. If enabled, the component fires rollover events on enter/exit of a cell which by default is promoted to the renderer if it implements RolloverRenderer, that is simulates live behaviour. The rollover events can be used by client code as well, f.i. to decorate the rollover row using a Highlighter.JXTree tree = new JXTree(); tree.setRolloverEnabled(true); tree.setCellRenderer(new DefaultTreeRenderer()); tree.addHighlighter(new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.RED);Location of Trigger for ComponentPopupMenu
JXList allows access to the mouse location that triggered the showing of the componentPopupMenu. This feature allows to implement dynamic cell-context sensitive popupMenus, either in the menu actions or in a PopupMenuListener.The example below selects the cell that was clicked, event being the
PopupMenuEventreceived in aPopupMenuListener.JXTree tree = (JXTree) ((JPopupMenu) e.getSource()).getInvoker(); Point trigger = tree.getPopupTriggerLocation(); if (trigger != null) { int row = tree.getRowForLocation(trigger.x, trigger.y); tree.setSelectionRow(row); }Search
As all SwingX collection views, a JXTree is searchable. A search action is registered in its ActionMap under the key "find". The default behaviour is to ask the SearchFactory to open a search component on this component. The default keybinding is retrieved from the SearchFactory, typically ctrl-f (or cmd-f for Mac). Client code can register custom actions and/or bindings as appropriate.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.
Miscellaneous
- Improved usability for editing: guarantees that the tree is the focusOwner if editing terminated by user gesture and guards against data corruption if focusLost while editing
- Access methods for selection colors, for consistency with JXTable, JXList
- Convenience methods and actions to expand, collapse all nodes
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classJXTree.CellEditorRemoverThis class tracks changes in the keyboard focus state.classJXTree.DelegatingRendererA decorator for the original TreeCellRenderer.-
Nested classes/interfaces inherited from class javax.swing.JTree
javax.swing.JTree.DropLocation, javax.swing.JTree.DynamicUtilTreeNode
-
-
Field Summary
-
Fields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, LARGE_MODEL_PROPERTY, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, ROW_HEIGHT_PROPERTY, SCROLLS_ON_EXPAND_PROPERTY, SELECTION_MODEL_PROPERTY, SHOWS_ROOT_HANDLES_PROPERTY, TOGGLE_CLICK_COUNT_PROPERTY, TREE_MODEL_PROPERTY, VISIBLE_ROW_COUNT_PROPERTY
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor and Description JXTree()Constructs aJXTreewith a sample model.JXTree(java.util.Hashtable<?,?> value)Constructs aJXTreecreated from a Hashtable which does not display with root.JXTree(java.lang.Object[] value)Constructs aJXTreewith each element of the specified array as the child of a new root node which is not displayed.JXTree(javax.swing.tree.TreeModel newModel)Constructs an instance ofJXTreewhich displays the root node -- the tree is created using the specified data model.JXTree(javax.swing.tree.TreeNode root)Constructs aJXTreewith the specified TreeNode as its root, which displays the root node.JXTree(javax.swing.tree.TreeNode root, boolean asksAllowsChildren)Constructs aJXTreewith 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(java.util.Vector<?> value)Constructs aJXTreewith each element of the specified Vector as the child of a new root node which is not displayed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddHighlighter(Highlighter highlighter)Appends aHighlighterto the end of the list of usedHighlighters.voidcollapseAll()Collapses all nodes in this tree.voidexpandAll()Expands all nodes in this tree.javax.swing.tree.TreeCellRenderergetCellRenderer()Highlighter[]getHighlighters()Returns theHighlighters used by this table.javax.swing.tree.TreePathgetNextMatch(java.lang.String prefix, int startingRow, javax.swing.text.Position.Bias bias)Overridden to respect the string representation, if any.java.awt.PointgetPopupLocation(java.awt.event.MouseEvent event)java.awt.PointgetPopupTriggerLocation()Returns the location of the mouseEvent that triggered the showing of the ComponentPopupMenu.SearchablegetSearchable()Returns a Searchable for this component, guaranteed to be not null.java.awt.ColorgetSelectionBackground()Returns the background color for selected cells.java.awt.ColorgetSelectionForeground()Returns the selection foreground color.javax.swing.tree.TreePath[]getSelectionPaths()int[]getSelectionRows()java.lang.StringgetStringAt(int row)Returns the string representation of the cell value at the given position.java.lang.StringgetStringAt(javax.swing.tree.TreePath path)Returns the string representation of the cell value at the given position.javax.swing.tree.TreeCellRenderergetWrappedCellRenderer()Returns the renderer installed by client code or the default if none has been set.voidinvalidateCellSizeCache()Invalidates cell size caching in the ui delegate.booleanisOverwriteRendererIcons()Returns a boolean indicating whether the per-tree icons should be copied to the renderer on setCellRenderer.booleanisRolloverEnabled()Returns a boolean indicating whether or not rollover support is enabled.voidremoveHighlighter(Highlighter highlighter)Removes the given Highlighter.voidremoveNotify()Overridden to release the CellEditorRemover, if any.voidsetCellRenderer(javax.swing.tree.TreeCellRenderer renderer)voidsetClosedIcon(javax.swing.Icon closedIcon)Sets the Icon to use for a closed folder node.voidsetCollapsedIcon(javax.swing.Icon collapsedIcon)Sets the Icon to use for the handle of a collapsed node.voidsetExpandedIcon(javax.swing.Icon expandedIcon)Sets the Icon to use for the handle of an expanded node.voidsetHighlighters(Highlighter... highlighters)Sets theHighlighters to the table, replacing any old settings.voidsetLeafIcon(javax.swing.Icon leafIcon)Sets the Icon to use for a leaf node.voidsetModel(javax.swing.tree.TreeModel newModel)voidsetOpenIcon(javax.swing.Icon openIcon)Sets the Icon to use for an open folder node.voidsetOverwriteRendererIcons(boolean overwrite)Property to control whether per-tree icons should be copied to the renderer on setCellRenderer.voidsetRolloverEnabled(boolean rolloverEnabled)Sets the property to enable/disable rollover support.voidsetSearchable(Searchable searchable)Sets the Searchable for this component.voidsetSelectionBackground(java.awt.Color selectionBackground)Sets the background color for selected cells.voidsetSelectionForeground(java.awt.Color selectionForeground)Sets the foreground color for selected cells.voidstartEditingAtPath(javax.swing.tree.TreePath path)voidupdateUI()-
Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, collapsePath, collapseRow, convertValueToText, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getClosestPathForLocation, getClosestRowForLocation, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, 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, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setDragEnabled, setDropMode, setEditable, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, stopEditing, treeDidChange
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, 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, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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
-
-
-
-
Constructor Detail
-
JXTree
public JXTree()
Constructs aJXTreewith a sample model. The default model used by this tree defines a leaf node as any node without children.
-
JXTree
public JXTree(java.lang.Object[] value)
Constructs aJXTreewith 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.- Parameters:
value- an array of objects that are children of the root.
-
JXTree
public JXTree(java.util.Vector<?> value)
Constructs aJXTreewith 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.- Parameters:
value- an Vector of objects that are children of the root.
-
JXTree
public JXTree(java.util.Hashtable<?,?> value)
Constructs aJXTreecreated 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.- Parameters:
value- a Hashtable containing objects that are children of the root.
-
JXTree
public JXTree(javax.swing.tree.TreeNode root)
Constructs aJXTreewith 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.- Parameters:
root- root node of this tree
-
JXTree
public JXTree(javax.swing.tree.TreeNode root, boolean asksAllowsChildren)Constructs aJXTreewith 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.- Parameters:
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;- See Also:
DefaultTreeModel.asksAllowsChildren
-
JXTree
public JXTree(javax.swing.tree.TreeModel newModel)
Constructs an instance ofJXTreewhich 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.- Parameters:
newModel- theTreeModelto use as the data model
-
-
Method Detail
-
getSearchable
public Searchable getSearchable()
Returns a Searchable for this component, guaranteed to be not null. This implementation lazily creates a TreeSearchable if necessary.- Returns:
- a not-null Searchable for this component.
- See Also:
setSearchable(Searchable),TreeSearchable
-
setSearchable
public void setSearchable(Searchable searchable)
Sets the Searchable for this component. If null, a default Searchable will be created and used.- Parameters:
searchable- the Searchable to use for this component, may be null to indicate using the default.- See Also:
getSearchable()
-
getStringAt
public java.lang.String getStringAt(int row)
Returns the string representation of the cell value at the given position.- Parameters:
row- the row index of the cell in view coordinates- Returns:
- the string representation of the cell value as it will appear in the table.
-
getStringAt
public java.lang.String getStringAt(javax.swing.tree.TreePath path)
Returns the string representation of the cell value at the given position.- Parameters:
path- the TreePath representing the node.- Returns:
- the string representation of the cell value as it will appear in the table, or null if the path is not visible.
-
getNextMatch
public javax.swing.tree.TreePath getNextMatch(java.lang.String prefix, int startingRow, javax.swing.text.Position.Bias bias)Overridden to respect the string representation, if any. This takes over completely (as compared to super), internally messaging the Searchable.PENDING JW: re-visit once we support deep node search.
- Overrides:
getNextMatchin classjavax.swing.JTree
-
collapseAll
public void collapseAll()
Collapses all nodes in this tree.
-
expandAll
public void expandAll()
Expands all nodes in this tree.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.
-
getSelectionRows
public int[] getSelectionRows()
Overridden to always return a not-null array (following SwingX convention).
- Overrides:
getSelectionRowsin classjavax.swing.JTree
-
getSelectionPaths
public javax.swing.tree.TreePath[] getSelectionPaths()
Overridden to always return a not-null array (following SwingX convention).
- Overrides:
getSelectionPathsin classjavax.swing.JTree
-
getSelectionBackground
public java.awt.Color getSelectionBackground()
Returns the background color for selected cells.- Returns:
- the
Colorused for the background of selected list items - See Also:
setSelectionBackground(java.awt.Color),setSelectionForeground(java.awt.Color)
-
getSelectionForeground
public java.awt.Color getSelectionForeground()
Returns the selection foreground color.- Returns:
- the
Colorobject for the foreground property - See Also:
setSelectionForeground(java.awt.Color),setSelectionBackground(java.awt.Color)
-
setSelectionForeground
public void setSelectionForeground(java.awt.Color selectionForeground)
Sets the foreground color for selected cells. Cell renderers can use this color to render text and graphics for selected cells.The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property.
- Parameters:
selectionForeground- theColorto use in the foreground for selected list items- See Also:
getSelectionForeground(),setSelectionBackground(java.awt.Color),JComponent.setForeground(java.awt.Color),JComponent.setBackground(java.awt.Color),JComponent.setFont(java.awt.Font)
-
setSelectionBackground
public void setSelectionBackground(java.awt.Color selectionBackground)
Sets the background color for selected cells. Cell renderers can use this color to the fill selected cells.The default value of this property is defined by the look and feel implementation.
This is a JavaBeans bound property.
- Parameters:
selectionBackground- theColorto use for the background of selected cells- See Also:
getSelectionBackground(),setSelectionForeground(java.awt.Color),JComponent.setForeground(java.awt.Color),JComponent.setBackground(java.awt.Color),JComponent.setFont(java.awt.Font)
-
updateUI
public void updateUI()
Overridden to update selection background/foreground. Mimicking behaviour of ui-delegates for JTable, JList.
- Overrides:
updateUIin classjavax.swing.JTree
-
setRolloverEnabled
public void setRolloverEnabled(boolean rolloverEnabled)
Sets the property to enable/disable rollover support. If enabled, the list fires property changes on per-cell mouse rollover state, i.e. when the mouse enters/leaves a list cell.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.
- Parameters:
rolloverEnabled- a boolean indicating whether or not the rollover functionality should be enabled.- See Also:
isRolloverEnabled(),getLinkController(),createRolloverProducer(),RolloverRenderer
-
isRolloverEnabled
public boolean isRolloverEnabled()
Returns a boolean indicating whether or not rollover support is enabled.- Returns:
- a boolean indicating whether or not rollover support is enabled.
- See Also:
setRolloverEnabled(boolean)
-
getPopupLocation
public java.awt.Point getPopupLocation(java.awt.event.MouseEvent event)
Overridden for bookkeeping: the given event location is stored for later access.
- Overrides:
getPopupLocationin classjavax.swing.JComponent- See Also:
getPopupTriggerLocation()
-
getPopupTriggerLocation
public java.awt.Point getPopupTriggerLocation()
Returns the location of the mouseEvent that triggered the showing of the ComponentPopupMenu.- Returns:
- the location of the mouseEvent that triggered the last showing of the ComponentPopup, or null if it was triggered by keyboard.
-
setHighlighters
public void setHighlighters(Highlighter... highlighters)
Sets theHighlighters 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.
- Parameters:
highlighters- zero or more not null highlighters to use for renderer decoration.- Throws:
java.lang.NullPointerException- if array is null or array contains null values.- See Also:
getHighlighters(),addHighlighter(Highlighter),removeHighlighter(Highlighter)
-
getHighlighters
public Highlighter[] getHighlighters()
Returns theHighlighters used by this table. Maybe empty, but guarantees to be never null.- Returns:
- the Highlighters used by this table, guaranteed to never null.
- See Also:
setHighlighters(Highlighter[])
-
addHighlighter
public void addHighlighter(Highlighter highlighter)
Appends aHighlighterto the end of the list of usedHighlighters. The argument must not be null.- Parameters:
highlighter- theHighlighterto add, must not be null.- Throws:
java.lang.NullPointerException- ifHighlighteris null.- See Also:
removeHighlighter(Highlighter),setHighlighters(Highlighter[])
-
removeHighlighter
public void removeHighlighter(Highlighter highlighter)
Removes the given Highlighter.Does nothing if the Highlighter is not contained.
- Parameters:
highlighter- the Highlighter to remove.- See Also:
addHighlighter(Highlighter),setHighlighters(Highlighter...)
-
setExpandedIcon
public void setExpandedIcon(javax.swing.Icon expandedIcon)
Sets the Icon to use for the handle of an expanded node.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.
- Parameters:
expandedIcon- the Icon to use for the handle of an expanded node.
-
setCollapsedIcon
public void setCollapsedIcon(javax.swing.Icon collapsedIcon)
Sets the Icon to use for the handle of a collapsed node. 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.- Parameters:
collapsedIcon- the Icon to use for the handle of a collapsed node.
-
setLeafIcon
public void setLeafIcon(javax.swing.Icon leafIcon)
Sets the Icon to use for a leaf node.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.
- Parameters:
leafIcon- the Icon to use for a leaf node.
-
setOpenIcon
public void setOpenIcon(javax.swing.Icon openIcon)
Sets the Icon to use for an open folder node. Note: this will only succeed if current renderer is a DefaultTreeCellRenderer. PENDING JW: incomplete api (no getter) and not a bound property.- Parameters:
openIcon- the Icon to use for an open folder node.
-
setClosedIcon
public void setClosedIcon(javax.swing.Icon closedIcon)
Sets the Icon to use for a closed folder node. Note: this will only succeed if current renderer is a DefaultTreeCellRenderer. PENDING JW: incomplete api (no getter) and not a bound property.- Parameters:
closedIcon- the Icon to use for a closed folder node.
-
setOverwriteRendererIcons
public void setOverwriteRendererIcons(boolean overwrite)
Property to control whether per-tree icons should be copied to the renderer on setCellRenderer.The default value is false. PENDING: should update the current renderer's icons when setting to true?
- Parameters:
overwrite- a boolean to indicate if the per-tree Icons should be copied to the new renderer on setCellRenderer.- See Also:
isOverwriteRendererIcons(),setLeafIcon(Icon),setOpenIcon(Icon),setClosedIcon(Icon)
-
isOverwriteRendererIcons
public boolean isOverwriteRendererIcons()
Returns a boolean indicating whether the per-tree icons should be copied to the renderer on setCellRenderer.- Returns:
- true if a TreeCellRenderer's icons will be overwritten with the tree's Icons, false if the renderer's icons will be unchanged.
- See Also:
setOverwriteRendererIcons(boolean),setLeafIcon(Icon),setOpenIcon(Icon),setClosedIcon(Icon)
-
getCellRenderer
public javax.swing.tree.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
- Overrides:
getCellRendererin classjavax.swing.JTree- See Also:
setCellRenderer(TreeCellRenderer),JXTree.DelegatingRenderer
-
getWrappedCellRenderer
public javax.swing.tree.TreeCellRenderer getWrappedCellRenderer()
Returns the renderer installed by client code or the default if none has been set.- Returns:
- the wrapped renderer.
- See Also:
setCellRenderer(TreeCellRenderer)
-
setCellRenderer
public void setCellRenderer(javax.swing.tree.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.- Overrides:
setCellRendererin classjavax.swing.JTree- See Also:
getWrappedCellRenderer(),getCellRenderer()
-
invalidateCellSizeCache
public void invalidateCellSizeCache()
Invalidates cell size caching in the ui delegate. May do nothing if there's no safe (i.e. without reflection) way to message the delegate.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.
-
startEditingAtPath
public void startEditingAtPath(javax.swing.tree.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.
- Overrides:
startEditingAtPathin classjavax.swing.JTree- See Also:
updateEditorRemover()
-
removeNotify
public void removeNotify()
Overridden to release the CellEditorRemover, if any.- Overrides:
removeNotifyin classjavax.swing.JComponent
-
setModel
public void setModel(javax.swing.tree.TreeModel newModel)
Overridden to initialize the String conversion method of the model, if any.
PENDING JW: remove - that is an outdated approach?
- Overrides:
setModelin classjavax.swing.JTree
-
-
DataMelt 3.0 © DataMelt by jWork.ORG