Class TableCellContext

java.lang.Object
org.jdesktop.swingx.renderer.CellContext
org.jdesktop.swingx.renderer.TableCellContext
All Implemented Interfaces:
Serializable

public class TableCellContext extends CellContext
Table specific CellContext. This implementation optionally can handle LAF provide alternateRowColor. The default is not doing it. To enable, client code must set a UI-Property with key HANDLE_ALTERNATE_ROW_BACKGROUND to Boolean.TRUE.
See Also:
  • Field Details

  • Constructor Details

    • TableCellContext

      public TableCellContext()
  • Method Details

    • installContext

      public void installContext(JTable component, Object value, int row, int column, boolean selected, boolean focused, boolean expanded, boolean leaf)
      Sets state of the cell's context. Note that the component might be null to indicate a cell without a concrete context. All accessors must cope with.
      Parameters:
      component - the component the cell resides on, might be null
      value - the content value of the cell
      row - the cell's row index in view coordinates
      column - the cell's column index in view coordinates
      selected - the cell's selected state
      focused - the cell's focused state
      expanded - the cell's expanded state
      leaf - the cell's leaf state
    • getComponent

      public JTable getComponent()
      Description copied from class: CellContext
      Returns the component the cell resides on, may be null. Subclasses are expected to override and return the component type they are handling.
      Overrides:
      getComponent in class CellContext
      Returns:
      the component the cell resides on, may be null.
    • isEditable

      public boolean isEditable()
      Returns the cell's editable property as returned by table.isCellEditable or false if the table is null.
      Overrides:
      isEditable in class CellContext
      Returns:
      the cell's editable property.
    • getBackground

      protected Color getBackground()
      Returns the background color of the renderered component or null if the component is null

      PENDING: fallback to UI properties if comp == null?

      Overridden to respect UI alternating row colors.

      Overrides:
      getBackground in class CellContext
      Returns:
      the background color of the rendered component.
    • getAlternateRowColor

      protected Color getAlternateRowColor()
      Returns a Color to for odd row background if this context should handle the alternating row color AND the UIManager has the alternateRowColor property set. Returns null otherwise.
      Returns:
      the color to use for odd row background, or null if either this context does not handle or no alternate row color is set.
    • getSelectionBackground

      protected Color getSelectionBackground()
      Returns the default selection background color of the renderered component. Typically, the color is LF specific. It's up to subclasses to look it up. Here: returns null.

      PENDING: return UI properties here?

      Overrides:
      getSelectionBackground in class CellContext
      Returns:
      the selection background color of the rendered component.
    • getSelectionForeground

      protected Color getSelectionForeground()
      Returns the default selection foreground color of the renderered component. Typically, the color is LF specific. It's up to subclasses to look it up. Here: returns null.

      PENDING: return UI properties here?

      Overrides:
      getSelectionForeground in class CellContext
      Returns:
      the selection foreground color of the rendered component.
    • getUIPrefix

      protected String getUIPrefix()
      Returns the component type specific prefix of keys for lookup in the UIManager. Subclasses must override, here: returns the empty String.
      Overrides:
      getUIPrefix in class CellContext
      Returns:
      the component type specific prefix.
    • isValidColumn

      protected boolean isValidColumn()
      PRE getComponent != null
      Returns:
      whether the column coordinate is valid in this context
    • isValidRow

      protected boolean isValidRow()
      PRE getComponent != null
      Returns:
      whether the row coordinate is valid in this context