Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private class Renderer extends DefaultTableCellRenderer
- {
- private static final long serialVersionUID = 1L;
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus,
- int row, int column)
- {
- super.getTableCellRendererComponent(table, value, isSelected,
- hasFocus, row, column);
- int columnIndex = table.getSelectedColumn();
- int rowIndex = table.getSelectedRow();
- if (columnIndex != -1 && rowIndex != -1){
- this.setBackground(Color.BLUE);
- } else {
- if (row % 2 == 0) this.setBackground(Color.decode("0xF9F9F9"));
- else this.setBackground(Color.decode("0xF1F1F1"));
- }
- return this;
- }
- }
- if (!isSelected) {
- setBackground(...);
- }
- HighlighterPipeline highlighters = new HighlighterPipeline();
- highlighters.addHighlighter(new AlternateRowHighlighter());
- table.setHighlighters(highlighters);
- JXTable table;
- Highlighter alternateStriping =
- HighlighterFactory.createAlternateStriping( Color.decode( "0xF9F9F9" ),
- Color.decode( "0xF1F1F1" ) );
- table.setHighlighters( alternateStriping );
Add Comment
Please, Sign In to add comment