Class EnablingCheckboxRenderer

All Implemented Interfaces:
ImageObserver, ItemSelectable, MenuContainer, Serializable, Accessible, SwingConstants, TableCellRenderer

public class EnablingCheckboxRenderer extends JCheckBox implements TableCellRenderer
Handle painting checkbox classes in a JTable.

Beyond the normal behavior of providing a checkbox to show the value, this disables the JCheckBox if the cell is not editable. This makes the visual behavior more in line with user expectations. The checkbox cell background is set to match selected status.

See Also:
  • Constructor Details

  • Method Details

    • getTableCellRendererComponent

      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
      Override this method from the parent class.
      Specified by:
      getTableCellRendererComponent in interface TableCellRenderer
      Parameters:
      table - the JTable component
      value - the cell content's object
      isSelected - boolean so we know if this is the currently selected row
      hasFocus - does this cell currently have focus?
      row - the row number
      column - the column number
      Returns:
      the JCheckBox to display