1
2
3
4 package ca.spaz.gui;
5
6 import java.awt.*;
7
8 import javax.swing.JTable;
9 import javax.swing.table.TableCellRenderer;
10
11 public class PrettyTable extends JTable {
12 private static final Color SHADED = new Color(240, 240, 255);
13
14 public PrettyTable() {
15 super();
16
17 this.setShowGrid(false);
18 }
19
20 public Component prepareRenderer(TableCellRenderer r, int row, int col) {
21 Component c = super.prepareRenderer(r, row, col);
22 if (row % 2 == 0) {
23 c.setBackground(Color.WHITE);
24 } else {
25 c.setBackground(SHADED);
26 }
27 if (getSelectionModel().isSelectedIndex(row)) {
28 c.setBackground(c.getBackground().darker());
29 }
30 return c;
31 }
32
33 }