Question

I need to highlight every other row in my JTable. With old version of swingx it could be done like this:

table.setHighlighters(new HighlighterPipeline(new Highlighter[] { new AlternateRowHighlighter(
            color1, color2,color3 }));

but now, with swingx 1.6, method setHighlighters() can't accept those parameters. It says "The method setHighlighters(Highlighter...) in the type JXTable is not applicable for the arguments (HighlighterPipeline)"

So how can i do it with new swingx?

Was it helpful?

Solution

To add stripping to your JXTable you need to use HighlighterFactory.
Try:

table.addHighlighter(HighlighterFactory.createSimpleStriping()); 

or:

table.addHighlighter(HighlighterFactory.createAlternateStriping(Color baseBackground, Color alternateBackground)); 

Alternatively, if you want to add multiple highlighters, you can use:

table.setHighlighters(Highlighter... highlighters); 

using always HighlighterFactory to create your highlighters.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top