Package swingtree

Class CellDelegate<C extends JComponent,V>

java.lang.Object
swingtree.CellDelegate<C,V>
Type Parameters:
V - The value type of the entry of this CellDelegate.

public class CellDelegate<C extends JComponent,V> extends Object
This class models the state of an individual table/list/drop down cell alongside various properties that a cell should have, like for example the value of the cell, its position within the table as well as a renderer in the form of a AWT Component which may or not be replaced or modified.
When configuring your cell, you may use methods like withRenderer(Component) or withRenderer(Consumer) to define how the cell should be rendered.
  • Constructor Details

    • CellDelegate

      public CellDelegate(C owner, @Nullable V value, boolean isSelected, boolean hasFocus, int row, int column, @Nullable Component renderer, List<String> toolTips, @Nullable Object presentationValue, Supplier<Component> defaultRenderSource)
  • Method Details

    • getComponent

      public C getComponent()
    • value

      public Optional<V> value()
    • valueAsString

      public Optional<String> valueAsString()
    • isSelected

      public boolean isSelected()
    • hasFocus

      public boolean hasFocus()
    • getRow

      public int getRow()
    • getColumn

      public int getColumn()
    • renderer

      public Optional<Component> renderer()
    • withRenderer

      public CellDelegate<C,V> withRenderer(Component component)
    • withRenderer

      public CellDelegate<C,V> withRenderer(Consumer<Graphics2D> painter)
    • withToolTip

      public CellDelegate<C,V> withToolTip(String toolTip)
    • presentationValue

      public Optional<Object> presentationValue()
      The presentation value is the first choice of the cell renderer to be used for rendering and presentation to the user. If it does not exist then the regular cell value is used for rendering.
      Returns:
      An optional of the presentation value. It may be an empty optional if no presentation value was specified.
    • withPresentationValue

      public CellDelegate<C,V> withPresentationValue(@Nullable Object toBeShown)
      Represents the value how it should be displayed to the user by the cell renderer. By default, this value is null, in which case the regular cell value is presented to the user.
      Parameters:
      toBeShown - The object which should be used by the renderer to present to the user, typically a String.
      Returns:
      An updated cell delegate object with the new presentation value.
    • withDefaultRenderer

      public CellDelegate<C,V> withDefaultRenderer()