APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.synth

public Class SynthTreeUI

extends BasicTreeUI
implements PropertyChangeListener, SynthUI
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.synth.SynthUI, javax.swing.plaf.synth.SynthConstants, java.beans.PropertyChangeListener, java.util.EventListener
Imports
java.awt.Color, .Component, .Graphics, .Insets, .Rectangle, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.util.Enumeration, javax.swing.DefaultCellEditor, .Icon, .JComponent, .JTextField, .JTree, .LookAndFeel, javax.swing.plaf.ComponentUI, .UIResource, javax.swing.plaf.basic.BasicTreeUI, javax.swing.tree.DefaultTreeCellEditor, .DefaultTreeCellRenderer, .TreeCellEditor, .TreeCellRenderer, .TreeModel, .TreePath

Provides the Synth L&F UI delegate for javax.swing.JTree.
Author
Scott Violet
Since
1.7

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
private class
SynthTreeUI.SynthTreeCellRenderer

A subclass of DefaultTreeCellRenderer that implements UIResource.

Field Summary

Modifier and TypeField and Description
private SynthStyle
private Icon
private boolean
private boolean
private Icon
private Object
private int
private SynthContext
private SynthStyle
private boolean
Inherited from javax.swing.plaf.basic.BasicTreeUI:
cellEditorcollapsedIconcreatedCellEditorcreatedRenderercurrentCellRendererdepthOffsetdrawingCacheeditingComponenteditingPatheditingRoweditorHasDifferentSizeexpandedIconlargeModellastSelectedRowleftChildIndentnodeDimensionspreferredMinSizepreferredSizerendererPanerightChildIndentstopEditingInCompleteEditingtotalChildIndenttreetreeModeltreeSelectionModeltreeStatevalidCachedPreferredSize

Constructor Summary

AccessConstructor and Description
public
SynthTreeUI()

Constructs a SynthTreeUI.

Method Summary

Modifier and TypeMethod and Description
private void
protected TreeCellEditor
protected TreeCellRenderer
createDefaultCellRenderer()

Overrides javax.swing.plaf.basic.BasicTreeUI.createDefaultCellRenderer.

Returns the default cell renderer that is used to do the stamping of each node.

public static ComponentUI

Returns:

the UI object
createUI
(JComponent
component to create UI object for
x
)

Hides javax.swing.plaf.basic.BasicTreeUI.createUI.

Creates a new UI object for the given component.

protected void
drawCentered(Component c, Graphics graphics, Icon icon, int x, int y)

Overrides javax.swing.plaf.basic.BasicTreeUI.drawCentered.

Draws the icon centered at (x,y).

private int
public Icon
private int
public SynthContext
getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

private SynthContext
getContext(JComponent c, int state)

private SynthContext
private SynthContext
getContext(JComponent c, Region region, int state)

public Icon
protected int
getRowX(int row, int depth)

Overrides javax.swing.plaf.basic.BasicTreeUI.getRowX.

Returns the location, along the x-axis, to render a particular row at.

protected void
protected void
public void
paint(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.basic.BasicTreeUI.paint.

Paints the specified component according to the Look and Feel.

protected void
paint(SynthContext
context for the component being painted
context
,
Graphics
the Graphics object used for painting
g
)

Paints the specified component.

public void
paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

protected void
protected void
paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintExpandControl.

Paints the expand (toggle) part of a row.

protected void
paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintHorizontalLine.

Paints a horizontal line.

protected void
paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintHorizontalPartOfLeg.

Paints the horizontal part of the leg.

private void
paintRow(TreeCellRenderer renderer, DefaultTreeCellRenderer dtcr, SynthContext treeContext, SynthContext cellContext, Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, Rectangle rowBounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)

protected void
paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintVerticalLine.

Paints a vertical line.

protected void
paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintVerticalPartOfLeg.

Paints the vertical part of the leg.

public void
propertyChange(PropertyChangeEvent event)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

private void
protected void
protected void
public void
update(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component.

private void
Inherited from javax.swing.plaf.basic.BasicTreeUI:
cancelEditingcheckForClickInExpandControlcompleteEditingcompleteEditingcompleteUIInstallcompleteUIUninstallconfigureLayoutCachecreateCellEditorListenercreateCellRendererPanecreateComponentListenercreateFocusListenercreateKeyListenercreateLayoutCachecreateMouseListenercreateNodeDimensionscreatePropertyChangeListenercreateSelectionModelPropertyChangeListenercreateTreeExpansionListenercreateTreeModelListenercreateTreeSelectionListenerdrawDashedHorizontalLinedrawDashedVerticalLineensureRowsAreVisiblegetBaselinegetBaselineResizeBehaviorgetCellEditorgetCellRenderergetClosestPathForLocationgetDropLineRectgetEditingPathgetHashColorgetHorizontalLegBuffergetLastChildPathgetLeadSelectionRowgetLeftChildIndentgetMaximumSizegetMinimumSizegetModelgetPathBoundsgetPathForRowgetPreferredMinSizegetPreferredSizegetPreferredSizegetRightChildIndentgetRowCountgetRowForPathgetRowHeightgetSelectionModelgetShowsRootHandlesgetVerticalLegBufferhandleExpandControlClickinstallComponentsinstallKeyboardActionsinstallUIisDropLineisEditableisEditingisLargeModelisLeafisLocationInExpandControlisMultiSelectEventisRootVisibleisToggleEventisToggleSelectionEventpaintRowpathWasCollapsedpathWasExpandedprepareForUIInstallprepareForUIUninstallselectPathForEventsetCellEditorsetCellRenderersetCollapsedIconsetEditablesetExpandedIconsetHashColorsetLargeModelsetLeftChildIndentsetModelsetPreferredMinSizesetRightChildIndentsetRootVisiblesetRowHeightsetSelectionModelsetShowsRootHandlesshouldPaintExpandControlstartEditingstartEditingAtPathstopEditingtoggleExpandStateuninstallComponentsuninstallKeyboardActionsuninstallUIupdateCachedPreferredSizeupdateCellEditorupdateDepthOffsetupdateExpandedDescendantsupdateLayoutCacheExpandedNodesupdateLeadSelectionRowupdateRendererupdateSize

Field Detail

cellStyleback to summary
private SynthStyle cellStyle
collapsedIconWrapperback to summary
private Icon collapsedIconWrapper
drawHorizontalLinesback to summary
private boolean drawHorizontalLines
drawVerticalLinesback to summary
private boolean drawVerticalLines
expandedIconWrapperback to summary
private Icon expandedIconWrapper
linesStyleback to summary
private Object linesStyle
paddingback to summary
private int padding
paintContextback to summary
private SynthContext paintContext
styleback to summary
private SynthStyle style
useTreeColorsback to summary
private boolean useTreeColors

Constructor Detail

SynthTreeUIback to summary
public SynthTreeUI()

Constructs a SynthTreeUI.

Method Detail

configureRendererback to summary
private void configureRenderer(SynthContext context)
createDefaultCellEditorback to summary
protected TreeCellEditor createDefaultCellEditor()

Overrides javax.swing.plaf.basic.BasicTreeUI.createDefaultCellEditor.

Doc from javax.swing.plaf.basic.BasicTreeUI.createDefaultCellEditor.

Creates a default cell editor.

Annotations
@Override
createDefaultCellRendererback to summary
protected TreeCellRenderer createDefaultCellRenderer()

Overrides javax.swing.plaf.basic.BasicTreeUI.createDefaultCellRenderer.

Doc from javax.swing.plaf.basic.BasicTreeUI.createDefaultCellRenderer.

Returns the default cell renderer that is used to do the stamping of each node.

Annotations
@Override
createUIback to summary
public static ComponentUI createUI(JComponent x)

Hides javax.swing.plaf.basic.BasicTreeUI.createUI.

Creates a new UI object for the given component.

Parameters
x:JComponent

component to create UI object for

Returns:ComponentUI

the UI object

drawCenteredback to summary
protected void drawCentered(Component c, Graphics graphics, Icon icon, int x, int y)

Overrides javax.swing.plaf.basic.BasicTreeUI.drawCentered.

Doc from javax.swing.plaf.basic.BasicTreeUI.drawCentered.

Draws the icon centered at (x,y).

Annotations
@Override
findCenteredXback to summary
private int findCenteredX(int x, int iconWidth)

Hides javax.swing.plaf.basic.BasicTreeUI.findCenteredX.

getCollapsedIconback to summary
public Icon getCollapsedIcon()

Overrides javax.swing.plaf.basic.BasicTreeUI.getCollapsedIcon.

Doc from javax.swing.plaf.basic.BasicTreeUI.getCollapsedIcon.

Returns the collapsed icon.

Annotations
@Override
getComponentStateback to summary
private int getComponentState(JComponent c, Region region)
getContextback to summary
public SynthContext getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Doc from javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

Annotations
@Override
getContextback to summary
private SynthContext getContext(JComponent c, int state)
getContextback to summary
private SynthContext getContext(JComponent c, Region region)
getContextback to summary
private SynthContext getContext(JComponent c, Region region, int state)
getExpandedIconback to summary
public Icon getExpandedIcon()

Overrides javax.swing.plaf.basic.BasicTreeUI.getExpandedIcon.

Doc from javax.swing.plaf.basic.BasicTreeUI.getExpandedIcon.

Returns the expanded icon.

Annotations
@Override
getRowXback to summary
protected int getRowX(int row, int depth)

Overrides javax.swing.plaf.basic.BasicTreeUI.getRowX.

Doc from javax.swing.plaf.basic.BasicTreeUI.getRowX.

Returns the location, along the x-axis, to render a particular row at. The return value does not include any Insets specified on the JTree. This does not check for the validity of the row or depth, it is assumed to be correct and will not throw an Exception if the row or depth doesn't match that of the tree.

Annotations
@Override
installDefaultsback to summary
protected void installDefaults()

Overrides javax.swing.plaf.basic.BasicTreeUI.installDefaults.

Doc from javax.swing.plaf.basic.BasicTreeUI.installDefaults.

Installs default properties.

Annotations
@Override
installListenersback to summary
protected void installListeners()

Overrides javax.swing.plaf.basic.BasicTreeUI.installListeners.

Doc from javax.swing.plaf.basic.BasicTreeUI.installListeners.

Registers listeners.

Annotations
@Override
paintback to summary
public void paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.basic.BasicTreeUI.paint.

Paints the specified component according to the Look and Feel.

This method is not used by Synth Look and Feel. Painting is handled by the paint(SynthContext, Graphics) method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
paintback to summary
protected void paint(SynthContext context, Graphics g)

Paints the specified component.

Parameters
context:SynthContext

context for the component being painted

g:Graphics

the Graphics object used for painting

See Also
update(Graphics, JComponent)
paintBorderback to summary
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Doc from javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

Annotations
@Override
paintDropLineback to summary
protected void paintDropLine(Graphics g)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintDropLine.

Doc from javax.swing.plaf.basic.BasicTreeUI.paintDropLine.

Paints the drop line.

Annotations
@Override
paintExpandControlback to summary
protected void paintExpandControl(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintExpandControl.

Doc from javax.swing.plaf.basic.BasicTreeUI.paintExpandControl.

Paints the expand (toggle) part of a row. The receiver should NOT modify clipBounds, or insets.

Annotations
@Override
paintHorizontalLineback to summary
protected void paintHorizontalLine(Graphics g, JComponent c, int y, int left, int right)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintHorizontalLine.

Doc from javax.swing.plaf.basic.BasicTreeUI.paintHorizontalLine.

Paints a horizontal line.

Annotations
@Override
paintHorizontalPartOfLegback to summary
protected void paintHorizontalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintHorizontalPartOfLeg.

Doc from javax.swing.plaf.basic.BasicTreeUI.paintHorizontalPartOfLeg.

Paints the horizontal part of the leg. The receiver should NOT modify clipBounds, or insets.

Note

parentRow can be -1 if the root is not visible.

Annotations
@Override
paintRowback to summary
private void paintRow(TreeCellRenderer renderer, DefaultTreeCellRenderer dtcr, SynthContext treeContext, SynthContext cellContext, Graphics g, Rectangle clipBounds, Insets insets, Rectangle bounds, Rectangle rowBounds, TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf)
paintVerticalLineback to summary
protected void paintVerticalLine(Graphics g, JComponent c, int x, int top, int bottom)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintVerticalLine.

Doc from javax.swing.plaf.basic.BasicTreeUI.paintVerticalLine.

Paints a vertical line.

Annotations
@Override
paintVerticalPartOfLegback to summary
protected void paintVerticalPartOfLeg(Graphics g, Rectangle clipBounds, Insets insets, TreePath path)

Overrides javax.swing.plaf.basic.BasicTreeUI.paintVerticalPartOfLeg.

Doc from javax.swing.plaf.basic.BasicTreeUI.paintVerticalPartOfLeg.

Paints the vertical part of the leg. The receiver should NOT modify clipBounds, insets.

Annotations
@Override
propertyChangeback to summary
public void propertyChange(PropertyChangeEvent event)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Annotations
@Override
repaintDropLocationback to summary
private void repaintDropLocation(JTree.DropLocation loc)
uninstallDefaultsback to summary
protected void uninstallDefaults()

Overrides javax.swing.plaf.basic.BasicTreeUI.uninstallDefaults.

Doc from javax.swing.plaf.basic.BasicTreeUI.uninstallDefaults.

Uninstalls default properties.

Annotations
@Override
uninstallListenersback to summary
protected void uninstallListeners()

Overrides javax.swing.plaf.basic.BasicTreeUI.uninstallListeners.

Doc from javax.swing.plaf.basic.BasicTreeUI.uninstallListeners.

Unregisters listeners.

Annotations
@Override
updateback to summary
public void update(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls the paint(SynthContext, Graphics) method.

In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the paint method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
updateStyleback to summary
private void updateStyle(JTree tree)
javax.swing.plaf.synth back to summary

private Class SynthTreeUI.IconWrapper

extends Object
implements SynthIcon
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.synth.SynthIcon, javax.swing.Icon

Field Summary

Modifier and TypeField and Description
pack-priv Icon

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
getIconHeight(SynthContext context)

Implements javax.swing.plaf.synth.SynthIcon.getIconHeight.

Returns the icon's height for the given synth context.

public int
getIconWidth(SynthContext context)

Implements javax.swing.plaf.synth.SynthIcon.getIconWidth.

Returns the icon's width for the given synth context.

public void
paintIcon(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthIcon.paintIcon.

Paints the icon at the specified location for the given synth context.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

iconTypeback to summary
pack-priv Icon iconType

Constructor Detail

IconWrapperback to summary
public IconWrapper(Icon type)

Method Detail

getIconHeightback to summary
public int getIconHeight(SynthContext context)

Implements javax.swing.plaf.synth.SynthIcon.getIconHeight.

Doc from javax.swing.plaf.synth.SynthIcon.getIconHeight.

Returns the icon's height for the given synth context.

getIconWidthback to summary
public int getIconWidth(SynthContext context)

Implements javax.swing.plaf.synth.SynthIcon.getIconWidth.

Doc from javax.swing.plaf.synth.SynthIcon.getIconWidth.

Returns the icon's width for the given synth context.

paintIconback to summary
public void paintIcon(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthIcon.paintIcon.

Doc from javax.swing.plaf.synth.SynthIcon.paintIcon.

Paints the icon at the specified location for the given synth context.

javax.swing.plaf.synth back to summary

private Class SynthTreeUI.SynthTreeCellEditor

extends DefaultTreeCellEditor
Class Inheritance

Field Summary

Inherited from javax.swing.tree.DefaultTreeCellEditor:
borderSelectionColorcanEditeditingComponenteditingContainereditingIconfontlastPathlastRowoffsetrealEditorrenderertimertree

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected TreeCellEditor
createTreeCellEditor()

Overrides javax.swing.tree.DefaultTreeCellEditor.createTreeCellEditor.

This is invoked if a TreeCellEditor is not supplied in the constructor.

Inherited from javax.swing.tree.DefaultTreeCellEditor:
actionPerformedaddCellEditorListenercancelCellEditingcanEditImmediatelycreateContainerdetermineOffsetgetBorderSelectionColorgetCellEditorListenersgetCellEditorValuegetFontgetTreeCellEditorComponentinHitRegionisCellEditableprepareForEditingremoveCellEditorListenersetBorderSelectionColorsetFontsetTreeshouldSelectCellshouldStartEditingTimerstartEditingTimerstopCellEditingvalueChanged

Constructor Detail

SynthTreeCellEditorback to summary
public SynthTreeCellEditor(JTree tree, DefaultTreeCellRenderer renderer)

Method Detail

createTreeCellEditorback to summary
protected TreeCellEditor createTreeCellEditor()

Overrides javax.swing.tree.DefaultTreeCellEditor.createTreeCellEditor.

Doc from javax.swing.tree.DefaultTreeCellEditor.createTreeCellEditor.

This is invoked if a TreeCellEditor is not supplied in the constructor. It returns a TextField editor.

Annotations
@Override
javax.swing.plaf.synth back to summary

private Class SynthTreeUI.SynthTreeCellRenderer

extends DefaultTreeCellRenderer
implements UIResource
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.UIResource
Annotations
@SuppressWarnings:serial

A subclass of DefaultTreeCellRenderer that implements UIResource.

Field Summary

Inherited from javax.swing.tree.DefaultTreeCellRenderer:
backgroundNonSelectionColorbackgroundSelectionColorborderSelectionColorclosedIconhasFocusleafIconopenIconselectedtextNonSelectionColortextSelectionColor

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
getName()

Overrides java.awt.Component.getName.

Gets the name of the component.

public Component
getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)

Overrides javax.swing.tree.DefaultTreeCellRenderer.getTreeCellRendererComponent.

Implements javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent.

Configures the renderer based on the passed in components.

public void
Inherited from javax.swing.tree.DefaultTreeCellRenderer:
firePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangefirePropertyChangegetBackgroundNonSelectionColorgetBackgroundSelectionColorgetBorderSelectionColorgetClosedIcongetDefaultClosedIcongetDefaultLeafIcongetDefaultOpenIcongetFontgetLeafIcongetOpenIcongetPreferredSizegetTextNonSelectionColorgetTextSelectionColorinvalidaterepaintrepaintrepaintrevalidatesetBackgroundsetBackgroundNonSelectionColorsetBackgroundSelectionColorsetBorderSelectionColorsetClosedIconsetFontsetLeafIconsetOpenIconsetTextNonSelectionColorsetTextSelectionColorupdateUIvalidate

Constructor Detail

SynthTreeCellRendererback to summary
pack-priv SynthTreeCellRenderer()

Method Detail

getNameback to summary
public String getName()

Overrides java.awt.Component.getName.

Doc from java.awt.Component.getName.

Gets the name of the component.

Annotations
@Override
getTreeCellRendererComponentback to summary
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)

Overrides javax.swing.tree.DefaultTreeCellRenderer.getTreeCellRendererComponent.

Implements javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent.

Doc from javax.swing.tree.DefaultTreeCellRenderer.getTreeCellRendererComponent.

Configures the renderer based on the passed in components. The value is set from messaging the tree with convertValueToText, which ultimately invokes toString on value. The foreground color is set based on the selection and the icon is set based on the leaf and expanded parameters.

Annotations
@Override
paintback to summary
public void paint(Graphics g)

Overrides javax.swing.tree.DefaultTreeCellRenderer.paint.

Doc from javax.swing.tree.DefaultTreeCellRenderer.paint.

Paints the value. The background is filled based on selected.

Annotations
@Override