/Users/lyon/j4p/src/gui/run/RunCheckBoxMenuItem.java

1    package gui.run; 
2     
3     
4    public abstract class RunCheckBoxMenuItem extends 
5            javax.swing.JCheckBoxMenuItem  
6            implements java.awt.event.ItemListener, Runnable { 
7        public RunCheckBoxMenuItem(String label) { 
8            this(label,false); 
9        } 
10    
11       public RunCheckBoxMenuItem(String s, boolean b) { 
12           super(s, b); 
13           addItemListener(this); 
14           ShortcutUtils.addShortcut(this); 
15       } 
16    
17       public RunCheckBoxMenuItem(javax.swing.Icon i) { 
18           super(i); 
19           addItemListener(this); 
20       } 
21    
22       public RunCheckBoxMenuItem() { 
23           addItemListener(this); 
24       } 
25    
26       public void itemStateChanged(java.awt.event.ItemEvent e) { 
27           run(); 
28       } 
29    
30       public static void main(String args[]) { 
31           gui.ClosableJFrame cf = new gui.ClosableJFrame("RunRadio"); 
32           java.awt.Container c = cf.getContentPane(); 
33    
34           javax.swing.JMenuBar mb = new javax.swing.JMenuBar(); 
35           RunMenu m = new RunMenu("[Checkable"); 
36           m.add(new RunCheckBoxMenuItem("Check[1{alt shift 1}") { 
37               public void run() { 
38                   System.out.println(getText()); 
39               } 
40           }); 
41           m.add(new RunCheckBoxMenuItem("Check[2{alt shift 2}") { 
42               public void run() { 
43                   System.out.println(getText()); 
44               } 
45           }); 
46    
47           mb.add(m); 
48           cf.setJMenuBar(mb); 
49    
50           c.setLayout(new java.awt.GridLayout(1, 0)); 
51           cf.setSize(200, 200); 
52           cf.setVisible(true); 
53       } 
54   }