View Javadoc

1   
2   
3   package org.catacomb.druid.swing;
4   
5   import org.catacomb.druid.event.LabelActor;
6   
7   import java.awt.event.ActionEvent;
8   import java.awt.event.ActionListener;
9   
10  import javax.swing.JCheckBoxMenuItem;
11  
12  
13  public final class DCheckboxMenuItem extends JCheckBoxMenuItem
14      implements ActionListener {
15      static final long serialVersionUID = 1001;
16  
17      String actionCommand;
18      String baseLabel;
19  
20      int ilang;
21  
22      public LabelActor ml;
23      DPopLabel mypl;
24  
25      public DCheckboxMenuItem(String s) {
26          this(s, null);
27      }
28  
29      public DCheckboxMenuItem(String s, DPopLabel pl) {
30          super(s);
31          mypl = pl;
32          setBaseLabel(s);
33          setActionCommand(s);
34          addActionListener(this);
35      }
36  
37      public DCheckboxMenuItem(String s, DPopLabel pl, boolean b) {
38          this(s, pl);
39          setSelected(b);
40      }
41  
42  
43      public String toString() {
44          return "DMenuItem " + baseLabel;
45      }
46  
47      public void setLabelActor(LabelActor ml) {
48          this.ml = ml;
49      }
50  
51      public void setBaseLabel(String s) {
52          baseLabel = s;
53          if (actionCommand == null) {
54              actionCommand = s;
55          }
56          setText(s);
57      }
58  
59      public void setActionCommand(String s) {
60          actionCommand = s;
61      }
62  
63  
64      public void actionPerformed(ActionEvent aev) {
65          if (ml != null) {
66              ml.labelAction(actionCommand, isSelected());
67          }
68      }
69  
70  
71  
72  
73      public String getBaseLabel() {
74          return baseLabel;
75      }
76  
77      public void checkName() {
78      }
79  
80  }