Package: groovy.swing.impl

## [Java] Class ClosureRenderer

- groovy.swing.impl.ClosureRenderer

- All Implemented Interfaces and Traits:
    ListCellRenderer, TableCellRenderer, TreeCellRenderer

      public class ClosureRenderer
      extends Object
      implements ListCellRenderer, TableCellRenderer, TreeCellRenderer

  Shared Swing renderer that delegates rendering customization to a Groovy closure.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `ClosureRenderer()` Creates a renderer with no update closure.
    `ClosureRenderer(Closure c)` Creates a renderer that delegates to the supplied closure.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public List` | `getChildren()` Returns the renderer children exposed to the update closure.
    `` | `public int` | `getColumn()` Returns the current column index.
    `` | `public JList` | `getList()` Returns the current list being rendered.
    `` | `public Component` | `getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)` Prepares list-rendering state and delegates component creation to render().
    `` | `public int` | `getRow()` Returns the current row index.
    `` | `public JTable` | `getTable()` Returns the current table being rendered.
    `` | `public Component` | `getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)` Prepares table-rendering state and delegates component creation to render().
    `` | `public JTree` | `getTree()` Returns the current tree being rendered.
    `` | `public Component` | `getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)` Prepares tree-rendering state and delegates component creation to render().
    `` | `public Closure` | `getUpdate()` Returns the update closure invoked during rendering.
    `` | `public Object` | `getValue()` Returns the current cell value.
    `` | `public boolean` | `isDefaultRenderer()` Returns whether the default renderer was used as the base renderer.
    `` | `public boolean` | `isExpanded()` Returns whether the current tree node is expanded.
    `` | `public boolean` | `isFocused()` Returns whether the current cell has focus.
    `` | `public boolean` | `isLeaf()` Returns whether the current tree node is a leaf.
    `` | `public boolean` | `isSelected()` Returns whether the current cell is selected.
    `` | `public boolean` | `isTableHeader()` Returns whether table rendering uses the table-header renderer.
    `` | `public void` | `setTableHeader(boolean tableHeader)` Configures whether table rendering should use the table-header renderer.
    `` | `public void` | `setUpdate(Closure update)` Sets the update closure invoked during rendering.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public ClosureRenderer()

      Creates a renderer with no update closure.

    - #### public ClosureRenderer(Closure c)

      Creates a renderer that delegates to the supplied closure.

      Parameters:
        `c` - the update closure

  - ### Method Detail

    - #### public List getChildren()

      Returns the renderer children exposed to the update closure.

      Returns:
        the renderer children

    - #### public int getColumn()

      Returns the current column index.

      Returns:
        the current column index, or `-1`

    - #### public JList getList()

      Returns the current list being rendered.

      Returns:
        the current list, or `null`

    - #### public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)

      Prepares list-rendering state and delegates component creation to render().

      Parameters:
        `list` - the list being rendered
        `value` - the current cell value
        `index` - the list index being rendered
        `isSelected` - whether the cell is selected
        `cellHasFocus` - whether the cell has focus
      Returns:
        the renderer component

    - #### public int getRow()

      Returns the current row index.

      Returns:
        the current row index

    - #### public JTable getTable()

      Returns the current table being rendered.

      Returns:
        the current table, or `null`

    - #### public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)

      Prepares table-rendering state and delegates component creation to render().

      Parameters:
        `table` - the table being rendered
        `value` - the current cell value
        `isSelected` - whether the cell is selected
        `hasFocus` - whether the cell has focus
        `row` - the model row being rendered
        `column` - the model column being rendered
      Returns:
        the renderer component

    - #### public JTree getTree()

      Returns the current tree being rendered.

      Returns:
        the current tree, or `null`

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

      Prepares tree-rendering state and delegates component creation to render().

      Parameters:
        `tree` - the tree being rendered
        `value` - the current node value
        `selected` - whether the row is selected
        `expanded` - whether the node is expanded
        `leaf` - whether the node is a leaf
        `row` - the tree row being rendered
        `hasFocus` - whether the row has focus
      Returns:
        the renderer component

    - #### public Closure getUpdate()

      Returns the update closure invoked during rendering.

      Returns:
        the update closure

    - #### public Object getValue()

      Returns the current cell value.

      Returns:
        the current value

    - #### public boolean isDefaultRenderer()

      Returns whether the default renderer was used as the base renderer.

      Returns:
        `true` when the default renderer provided the base component

    - #### public boolean isExpanded()

      Returns whether the current tree node is expanded.

      Returns:
        `true` when the current node is expanded

    - #### public boolean isFocused()

      Returns whether the current cell has focus.

      Returns:
        `true` when the current cell has focus

    - #### public boolean isLeaf()

      Returns whether the current tree node is a leaf.

      Returns:
        `true` when the current node is a leaf

    - #### public boolean isSelected()

      Returns whether the current cell is selected.

      Returns:
        `true` when the current cell is selected

    - #### public boolean isTableHeader()

      Returns whether table rendering uses the table-header renderer.

      Returns:
        `true` when header rendering is enabled

    - #### public void setTableHeader(boolean tableHeader)

      Configures whether table rendering should use the table-header renderer.

      Parameters:
        `tableHeader` - `true` to render using the table-header renderer

    - #### public void setUpdate(Closure update)

      Sets the update closure invoked during rendering.

      Parameters:
        `update` - the update closure