public class MetalTreeUI extends BasicTreeUI
TreeUI.
MetalTreeUI allows for configuring how to visually render the spacing and delineation between nodes. The following hints are supported:
Angled |
A line is drawn connecting the child to the parent. For handling of the root node refer to JTree and JTree. |
|---|---|
Horizontal |
A horizontal line is drawn dividing the children of the root node. |
None |
Do not draw any visual indication between nodes. |
As it is typically impractical to obtain the TreeUI from the JTree and cast to an instance of MetalTreeUI you enable this property via the client property JTree.lineStyle. For example, to switch to Horizontal style you would do: tree.putClientProperty("JTree.lineStyle", "Horizontal");
The default is Angled.
BasicTreeUI.CellEditorHandler , BasicTreeUI.ComponentHandler , BasicTreeUI.FocusHandler , BasicTreeUI.KeyHandler , BasicTreeUI.MouseHandler , BasicTreeUI.MouseInputHandler , BasicTreeUI.NodeDimensionsHandler , BasicTreeUI.PropertyChangeHandler , BasicTreeUI.SelectionModelPropertyChangeHandler , BasicTreeUI.TreeCancelEditingAction , BasicTreeUI.TreeExpansionHandler , BasicTreeUI.TreeHomeAction , BasicTreeUI.TreeIncrementAction , BasicTreeUI.TreeModelHandler , BasicTreeUI.TreePageAction , BasicTreeUI.TreeSelectionHandler , BasicTreeUI.TreeToggleAction , BasicTreeUI.TreeTraverseAction cellEditor, collapsedIcon, createdCellEditor, createdRenderer, currentCellRenderer, depthOffset, drawingCache, editingComponent, editingPath, editingRow, editorHasDifferentSize, expandedIcon, largeModel, lastSelectedRow, leftChildIndent, nodeDimensions, preferredMinSize, preferredSize, rendererPane, rightChildIndent, stopEditingInCompleteEditing, totalChildIndent, tree, treeModel, treeSelectionModel, treeState, validCachedPreferredSize| Constructor and Description |
|---|
MetalTreeUI()
|
| Modifier and Type | Method and Description |
|---|---|
static ComponentUI |
createUI(JComponent
|
protected void |
decodeLineStyle(Object
this function converts between the string passed into the client property and the internal representation (currently and int)
|
protected int |
getHorizontalLegBuffer()
The horizontal element of legs between nodes starts at the right of the left-hand side of the child node by default.
|
void |
installUI(JComponent
Configures the specified component appropriately for the look and feel.
|
protected boolean |
isLocationInExpandControl(int row, int rowLevel, int mouseX, int mouseY)
|
void |
paint(Graphics
Paints the specified component appropriately for the look and feel.
|
protected void |
paintHorizontalPartOfLeg(Graphics
Paints the horizontal part of the leg.
|
protected void |
paintHorizontalSeparators(Graphics
|
protected void |
paintVerticalPartOfLeg(Graphics
Paints the vertical part of the leg.
|
void |
uninstallUI(JComponent
Reverses configuration which was done on the specified component during
installUI.
|
cancelEditing, checkForClickInExpandControl, completeEditing, completeEditing, completeUIInstall, completeUIUninstall, configureLayoutCache, createCellEditorListener, createCellRendererPane, createComponentListener, createDefaultCellEditor, createDefaultCellRenderer, createFocusListener, createKeyListener, createLayoutCache, createMouseListener, createNodeDimensions, createPropertyChangeListener, createSelectionModelPropertyChangeListener, createTreeExpansionListener, createTreeModelListener, createTreeSelectionListener, drawCentered, drawDashedHorizontalLine, drawDashedVerticalLine, ensureRowsAreVisible, getBaseline, getBaselineResizeBehavior, getCellEditor, getCellRenderer, getClosestPathForLocation, getCollapsedIcon, getDropLineRect, getEditingPath, getExpandedIcon, getHashColor, getLastChildPath, getLeadSelectionRow, getLeftChildIndent, getMaximumSize, getMinimumSize, getModel, getPathBounds, getPathForRow, getPreferredMinSize, getPreferredSize, getPreferredSize, getRightChildIndent, getRowCount, getRowForPath, getRowHeight, getRowX, getSelectionModel, getShowsRootHandles, getVerticalLegBuffer, handleExpandControlClick, installComponents, installDefaults, installKeyboardActions, installListeners, isDropLine, isEditable, isEditing, isLargeModel, isLeaf, isLocationInExpandControl, isMultiSelectEvent, isRootVisible, isToggleEvent, isToggleSelectionEvent, paintDropLine, paintExpandControl, paintHorizontalLine, paintRow, paintVerticalLine, pathWasCollapsed, pathWasExpanded, prepareForUIInstall, prepareForUIUninstall, selectPathForEvent, setCellEditor, setCellRenderer, setCollapsedIcon, setEditable, setExpandedIcon, setHashColor, setLargeModel, setLeftChildIndent, setModel, setPreferredMinSize, setRightChildIndent, setRootVisible, setRowHeight, setSelectionModel, setShowsRootHandles, shouldPaintExpandControl, startEditing, startEditingAtPath, stopEditing, toggleExpandState, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, updateCachedPreferredSize, updateCellEditor, updateDepthOffset, updateExpandedDescendants, updateLayoutCacheExpandedNodes, updateLeadSelectionRow, updateRenderer, updateSizecontains, getAccessibleChild, getAccessibleChildrenCount, updatepublic static ComponentUIcreateUI(JComponent x)
protected int getHorizontalLegBuffer()
BasicTreeUI
public void installUI(JComponentc)
ComponentUI
ComponentUI instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:
LayoutManager on the component if necessary. PropertyChangeListener on the component in order to detect and respond to component property changes appropriately. installUI in class
BasicTreeUI
c - the component where this UI delegate is being installed
ComponentUI.uninstallUI(javax.swing.JComponent) ,
JComponent.setUI(javax.swing.plaf.ComponentUI) ,
JComponent.updateUI()
public void uninstallUI(JComponentc)
ComponentUI
installUI. This method is invoked when this
UIComponent instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in
installUI, being careful to leave the
JComponent instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:
uninstallUI in class
BasicTreeUI
c - the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
ComponentUI.installUI(javax.swing.JComponent) ,
JComponent.updateUI()
protected void decodeLineStyle(ObjectlineStyleFlag)
protected boolean isLocationInExpandControl(int row,
int rowLevel,
int mouseX,
int mouseY)public void paint(Graphicsg, JComponent c)
ComponentUI
ComponentUI.update method when the specified component is being painted. Subclasses should override this method and use the specified
Graphics object to render the content of the component.
paint in class
BasicTreeUI
g - the
Graphics context in which to paint
c - the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected void paintHorizontalSeparators(Graphicsg, JComponent c)
protected void paintVerticalPartOfLeg(Graphicsg, Rectangle clipBounds, Insets insets, TreePath path)
BasicTreeUI
clipBounds,
insets.
protected void paintHorizontalPartOfLeg(Graphicsg, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
BasicTreeUI
clipBounds, or
insets.
NOTE: parentRow can be -1 if the root is not visible.