1 2 package org.catacomb.druid.swing; 3 4 import org.catacomb.druid.event.LabelActor; 5 import org.catacomb.report.E; 6 7 import java.awt.event.ActionEvent; 8 import java.awt.event.ActionListener; 9 10 import javax.swing.JMenuItem; 11 12 13 public class DMenuItem extends JMenuItem implements ActionListener { 14 static final long serialVersionUID = 1001; 15 16 String actionCommand; 17 String baseLabel; 18 19 int ilang; 20 21 LabelActor lactor; 22 23 24 public DMenuItem(String s) { 25 this(s, s); 26 } 27 28 29 public DMenuItem(String s, String a) { 30 super(s); 31 setBaseLabel(s); 32 setActionCommand(a); 33 addActionListener(this); 34 setBackground(LAF.getBackgroundColor()); 35 } 36 37 38 public String toString() { 39 return "DMenuItem " + baseLabel; 40 } 41 42 43 44 45 public void setBaseLabel(String s) { 46 baseLabel = s; 47 if (actionCommand == null) { 48 actionCommand = s; 49 } 50 setText(s); 51 } 52 53 public void setActionCommand(String s) { 54 actionCommand = s; 55 } 56 57 58 public void actionPerformed(ActionEvent aev) { 59 labelAction(actionCommand, true); 60 } 61 62 63 public void setLabelActor(LabelActor la) { 64 lactor = la; 65 } 66 67 public void labelAction(String s, boolean b) { 68 if (lactor == null) { 69 E.warning("non-overridden label action in menu " + 70 "and no label actor set " + baseLabel); 71 } else { 72 lactor.labelAction(s, b); 73 } 74 } 75 76 77 public String getBaseLabel() { 78 return baseLabel; 79 } 80 81 public void checkName() { 82 83 } 84 85 }