Insubstantial / insubstantial

Swing look-and-feel library and assorted widgets
193 stars 57 forks source link

Custom ListCellRenderer not inheriting from SubstanceDefaultListCellRenderer #111

Open cmadsen opened 11 years ago

cmadsen commented 11 years ago

I'm trying to do

class CheckBoxListRenderer extends JCheckBox implements ListCellRenderer 

but the Substance highlighting/striping etc will only work for SubstanceDefaultListCellRenderer.

Would it be possible to lessen the requirements to list cell renders to implement an interface/annotation or perhaps just add a new list cell renderer like SubstanceDefaultTableCellRenderer.BooleanRenderer?

fpaaske commented 11 years ago

It's the same issue with implements TableCellRenderer I'd love to see some solution that does not require the application to introduce dependencies to the LAF :-)

xmedeko commented 11 years ago

The problem is in the SubstanceTableUI.isSubstanceDefaultRenderer:

return (instance instanceof SubstanceDefaultTableCellRenderer)
        || (instance instanceof SubstanceDefaultTableCellRenderer.BooleanRenderer);

I think the solution 1) may be to use some kind of tag to decide, whether to use Substance highlighting/striping or not. It can be either an annotationor, (empty) interface, or a JComponent client property.

Another simple solution 2) could be to make this method protected/public to allow override it. Or, the best, do both 1) and 2).