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 |
0 |
private static final Color SHADED = new Color(240, 240, 255); |
13 |
|
|
14 |
|
public PrettyTable() { |
15 |
0 |
super(); |
16 |
|
|
17 |
0 |
this.setShowGrid(false); |
18 |
0 |
} |
19 |
|
|
20 |
|
public Component prepareRenderer(TableCellRenderer r, int row, class="keyword">int col) { |
21 |
0 |
Component c = super.prepareRenderer(r, row, col); |
22 |
0 |
if (row % 2 == 0) { |
23 |
0 |
c.setBackground(Color.WHITE); |
24 |
0 |
} else { |
25 |
0 |
c.setBackground(SHADED); |
26 |
|
} |
27 |
0 |
if (getSelectionModel().isSelectedIndex(row)) { |
28 |
0 |
c.setBackground(c.getBackground().darker()); |
29 |
|
} |
30 |
0 |
return c; |
31 |
|
} |
32 |
|
|
33 |
|
} |