How to use swingx 1.6 to highlight every other line in JTable
•
Java
I need to highlight each line in JTable Using an older version of swingx, you can do this:
table.setHighlighters(new HighlighterPipeline(new Highlighter[] { new AlternateRowHighlighter( color1,color2,color3 }));
But now, with swingx 1.6, the method sethighlights () cannot accept these parameters It says "the method sethighlighters (highlighter...) in jxtable type is not applicable to parameter (highlighterpipeline)"
So how can I use the new swingx?
Solution
To add a split to jxtable, you need to use highlighterfactory Try:
table.addHighlighter(HighlighterFactory.createSimpleStriping());
or
table.addHighlighter(HighlighterFactory.createAlternateStriping(Color baseBackground,Color alternateBackground));
Or, if you want to add more than one highlighter, you can use:
table.setHighlighters(Highlighter... Highlighters);
Use highlighterfactory to create a highlighter pen
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码