Class WrappingIconPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable, PainterAware

public class WrappingIconPanel extends JXPanel implements PainterAware
Compound component for usage in tree renderer.

Supports setting an icon for the node and a delegate component which is used to show the text/content of the node. The delegate component can be shared across renderers.

This implements the PainterAware by delegating to the delegate component if that is of type PainterAware. Does nothing if not.

See Also:
  • Field Details

  • Constructor Details

    • WrappingIconPanel

      public WrappingIconPanel()
      Instantiates and configures a WrappingIconPanel with the dropHack enabled.
    • WrappingIconPanel

      public WrappingIconPanel(boolean dropHackEnabled)
      Instantiates and configures a WrappingIconPanel with the dropHack property set as indicated by the boolean.
      Parameters:
      dropHackEnabled - a boolean indicating whether the drop hack should be enabled.
      See Also:
  • Method Details

    • setComponentOrientation

      public void setComponentOrientation(ComponentOrientation o)

      Overridden to update the icon position.

      Overrides:
      setComponentOrientation in class Component
    • setIcon

      public void setIcon(Icon icon)
      Sets the icon.
      Parameters:
      icon - the icon to use.
    • getIcon

      public Icon getIcon()
      Returns the icon used in this panel, may be null.
      Returns:
      the icon used in this panel, may be null.
    • setComponent

      public void setComponent(JComponent comp)
      Sets the delegate component.
      Parameters:
      comp - the component to add as delegate.
    • getComponent

      public JComponent getComponent()
      Returns the delegate component.
      Returns:
      the delegate component.
    • setBackground

      public void setBackground(Color bg)
      Sets the background color for this component by

      Overridden to set the background of the delegate and icon label as well.

      Overrides:
      setBackground in class JXPanel
      Parameters:
      bg - the desired background Color
      See Also:
    • setForeground

      public void setForeground(Color bg)

      Overridden to set the foreground of the delegate and icon label as well.

      Overrides:
      setForeground in class JComponent
    • setFont

      public void setFont(Font font)

      Overridden to set the Font of the delegate as well.

      Overrides:
      setFont in class JComponent
    • isVisible

      public boolean isVisible()

      Overridden to hack around #766-swingx: cursor flickering in DnD when dragging over tree column. This is a core bug (#6700748) related to painting the rendering component on a CellRendererPane. A trick around is to let this return false.

      Some LayoutManagers don't layout an invisible component, so need to make the hack-enabled configurable. This implementation will return false if isDropHackEnabled, super.isVisible otherwise.

      Overrides:
      isVisible in class Component
    • getPainter

      public Painter<?> getPainter()

      Returns the delegate's Painter if it is of type PainterAware or null otherwise.

      Specified by:
      getPainter in interface PainterAware
      Returns:
      the delegate's Painter or null.
    • setPainter

      public void setPainter(Painter<?> painter)
      Sets the delegate's Painter if it is of type PainterAware. Does nothing otherwise.
      Specified by:
      setPainter in interface PainterAware
      Parameters:
      painter - the Painter to apply to the delegate.
    • getDelegateBounds

      public Rectangle getDelegateBounds()
      Returns the bounds of the delegate component or null if the delegate is null. PENDING JW: where do we use it? Maybe it was for testing only?
      Returns:
      the bounds of the delegate, or null if the delegate is null.
    • setDropHackEnabled

      public void setDropHackEnabled(boolean dropHackEnabled)
      Sets the dropHackEnabled property.

      The default value is true.

      Parameters:
      dropHackEnabled -
      See Also: