1
2 package hoplugins.transfers.ui;
3
4 import java.awt.Color;
5 import java.awt.Component;
6
7 import javax.swing.JTable;
8 import javax.swing.table.DefaultTableCellRenderer;
9
10
11 /***
12 * Cell reneder to show an icon for the type of transfer (in or out).
13 *
14 * @author <a href=mailto:nethyperon@users.sourceforge.net>Boy van der Werf</a>
15 */
16 public class ColorCellRenderer extends DefaultTableCellRenderer {
17
18
19 /*** TODO Missing Parameter Documentation */
20 public static final Color GREEN = new Color(220, 255, 220);
21
22 /*** TODO Missing Parameter Documentation */
23 public static final Color YELLOW = new Color(255, 255, 200);
24
25
26
27 private Color color;
28
29
30
31 /***
32 * Creates an instance of ColorcellRenderer.
33 *
34 * @param color Color tto use
35 */
36 public ColorCellRenderer(Color color) {
37 super();
38 this.color = color;
39 }
40
41
42
43 /*** {@inheritDoc} */
44 public final Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
45 boolean hasFocus, int row, int column) {
46 super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
47
48 if (!isSelected) {
49 this.setBackground(this.color);
50 }
51
52 final int intVal = ((Integer) value).intValue();
53
54 if (intVal == 0) {
55 setText("---");
56 }
57
58 return this;
59 }
60 }