|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.plaf.ComponentUI javax.swing.plaf.TreeUI javax.swing.plaf.basic.BasicTreeUI javax.swing.plaf.metal.MetalTreeUI
The metal look and feel implementation of 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.setRootVisible(boolean) and
JTree.setShowsRootHandles(boolean) .
|
---|---|
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 impratical 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
.
Nested Class Summary | |
(package private) class |
MetalTreeUI.LineListener
This class listens for changes in line style |
Field Summary | |
private static int |
HORIZ_LINE_STYLE
|
private static String |
HORIZ_STYLE_STRING
|
private static int |
LEG_LINE_STYLE
|
private static String |
LEG_LINE_STYLE_STRING
|
private static String |
LINE_STYLE
|
private static Color |
lineColor
|
private int |
lineStyle
|
private java.beans.PropertyChangeListener |
lineStyleListener
|
private static int |
NO_LINE_STYLE
|
private static String |
NO_STYLE_STRING
|
Fields inherited from class javax.swing.plaf.basic.BasicTreeUI |
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 Summary | |
MetalTreeUI()
|
Method Summary | |
static ComponentUI |
createUI(JComponent x)
Returns an instance of the UI delegate for the specified component. |
protected void |
decodeLineStyle(Object lineStyleFlag)
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 c)
Configures the specified component appropriate for the look and feel. |
protected boolean |
isLocationInExpandControl(int row,
int rowLevel,
int mouseX,
int mouseY)
|
void |
paint(Graphics g,
JComponent c)
Paints the specified component appropriate for the look and feel. |
protected void |
paintHorizontalPartOfLeg(Graphics g,
Rectangle clipBounds,
Insets insets,
Rectangle bounds,
TreePath path,
int row,
boolean isExpanded,
boolean hasBeenExpanded,
boolean isLeaf)
Paints the horizontal part of the leg. |
protected void |
paintHorizontalSeparators(Graphics g,
JComponent c)
|
protected void |
paintVerticalPartOfLeg(Graphics g,
Rectangle clipBounds,
Insets insets,
TreePath path)
Paints the vertical part of the leg. |
void |
uninstallUI(JComponent c)
Reverses configuration which was done on the specified component during installUI . |
Methods inherited from class javax.swing.plaf.ComponentUI |
contains, getAccessibleChild, getAccessibleChildrenCount, update |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static Color lineColor
private static final String LINE_STYLE
private static final String LEG_LINE_STYLE_STRING
private static final String HORIZ_STYLE_STRING
private static final String NO_STYLE_STRING
private static final int LEG_LINE_STYLE
private static final int HORIZ_LINE_STYLE
private static final int NO_LINE_STYLE
private int lineStyle
private java.beans.PropertyChangeListener lineStyleListener
Constructor Detail |
public MetalTreeUI()
Method Detail |
public static ComponentUI createUI(JComponent x)
ComponentUI
createUI
method that returns an instance of that UI delegate subclass.
If the UI delegate subclass is stateless, it may return an instance
that is shared by multiple components. If the UI delegate is
stateful, then it should return a new instance per component.
The default implementation of this method throws an error, as it
should never be invoked.
protected int getHorizontalLegBuffer()
BasicTreeUI
getHorizontalLegBuffer
in class BasicTreeUI
public void installUI(JComponent c)
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
public void uninstallUI(JComponent c)
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
protected void decodeLineStyle(Object lineStyleFlag)
protected boolean isLocationInExpandControl(int row, int rowLevel, int mouseX, int mouseY)
public void paint(Graphics g, 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
protected void paintHorizontalSeparators(Graphics g, JComponent c)
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)
BasicTreeUI
clipBounds
, insets
.
paintVerticalPartOfLeg
in class BasicTreeUI
protected void paintHorizontalPartOfLeg(Graphics g, 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.
paintHorizontalPartOfLeg
in class BasicTreeUI
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |