1 package com.explosion.utilities.preferences.editandrender.table;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import java.awt.Color;
24 import java.awt.Component;
25
26 import javax.swing.JCheckBox;
27 import javax.swing.JTable;
28 import javax.swing.table.TableCellRenderer;
29
30 import com.explosion.utilities.preferences.Preference;
31
32 public class BooleanPreferenceRenderer extends JCheckBox implements TableCellRenderer
33 {
34
35 public BooleanPreferenceRenderer()
36 {
37 super();
38 setBackground(Color.WHITE);
39
40 }
41
42 public Component getTableCellRendererComponent(JTable table, Object prefrence, boolean isSelected, boolean hasFocus, int row, int column)
43 {
44
45 Preference pref = (Preference) prefrence;
46 Object renderableValue = pref.getValue();
47 if (renderableValue == null && pref.getDefaultValue() != null)
48 renderableValue = pref.getDefaultValue();
49
50 if (renderableValue == null)
51 this.setSelected(false);
52 else
53 this.setSelected(((Boolean)pref.getValue()).booleanValue());
54
55 return this;
56 }
57 }