1
2
3 package org.catacomb.druid.swing;
4
5 import org.catacomb.druid.event.LabelActor;
6 import org.catacomb.interlish.interact.DComponent;
7 import org.catacomb.interlish.structure.MouseActor;
8
9
10 import java.awt.Color;
11 import java.awt.Font;
12 import java.awt.event.ActionEvent;
13 import java.awt.event.ActionListener;
14
15 import javax.swing.JCheckBox;
16
17
18 public class DCheckbox extends JCheckBox implements DComponent, ActionListener {
19 static final long serialVersionUID = 1001;
20
21 String label;
22 String actionCommand;
23
24 RolloverEffect rollover;
25
26 LabelActor lact;
27
28 public DCheckbox(String lab) {
29 this(lab, null);
30
31 }
32
33 public DCheckbox(String lab,
34 String action) {
35 super(lab);
36 label = lab;
37
38 setFont(new Font("sansserif", Font.PLAIN, 12));
39
40 this.label = lab;
41 addActionListener(this);
42 setFocusPainted(false);
43
44 }
45
46 public void setTooltip(String s) {
47 setToolTipText(s);
48 }
49
50 public void setBg(Color c) {
51 setBackground(c);
52 }
53
54
55 public void setMouseActor(MouseActor ma) {
56 addMouseListener(new DMouseRelay(ma));
57 }
58
59
60 public boolean isChecked() {
61 return isSelected();
62 }
63
64 public void setActionCommand(String s) {
65 actionCommand = s;
66 }
67
68
69 public void actionPerformed(ActionEvent aev) {
70 deliverAction(label, isSelected());
71 }
72
73
74 public String toString() {
75 return "DButton " + label;
76 }
77
78
79
80 public void setLabelActor(LabelActor bl) {
81 lact = bl;
82 }
83
84
85
86 public void setBaseLabel(String s) {
87 setText(s);
88 }
89
90
91 public String getBaseLabel() {
92 return label;
93 }
94
95
96 public void deliverAction(String sin, boolean b) {
97 String s = sin;
98 if (actionCommand != null) {
99 s = actionCommand;
100 }
101 if (lact != null) {
102 lact.labelAction(s, b);
103 }
104 }
105
106 public String getStringIdentifier() {
107 return label;
108 }
109
110 }
111
112
113
114
115
116
117
118