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

1    package gui.run; 
2     
3     
4    public abstract class RunRadio extends 
5            javax.swing.JRadioButton implements java.awt.event.ItemListener, Runnable { 
6     
7        public RunRadio() { 
8            addItemListener(this); 
9        } 
10    
11       public RunRadio(javax.swing.Icon i) { 
12           super(i); 
13           addItemListener(this); 
14       } 
15    
16       public RunRadio(String s) { 
17           this(s, null); 
18           addItemListener(this); 
19       } 
20    
21       public RunRadio(String s, javax.swing.Icon i) { 
22           super(s, i); 
23           addItemListener(this); 
24           ShortcutUtils.addShortcut(this); 
25       } 
26    
27       public RunRadio(javax.swing.Icon i, boolean b) { 
28           super(i, b); 
29           addItemListener(this); 
30       } 
31    
32       public RunRadio(String s, boolean b) { 
33           super(s, b); 
34           addItemListener(this); 
35           ShortcutUtils.addShortcut(this); 
36       } 
37    
38       public RunRadio(String s, javax.swing.Icon i, boolean b) { 
39           super(s, i, b); 
40           addItemListener(this); 
41           ShortcutUtils.addShortcut(this); 
42       } 
43    
44    
45       public void itemStateChanged(java.awt.event.ItemEvent e) { 
46           run(); 
47       } 
48    
49       public static void main(String args[]) { 
50           gui.ClosableJFrame cf = new gui.ClosableJFrame("RunRadio"); 
51           java.awt.Container c = cf.getContentPane(); 
52    
53           c.add(new RunRadio("[black keys") { 
54               public void run() { 
55                   System.out.println(isSelected() + "set up black keys"); 
56               } 
57           } 
58           ); 
59    
60           c.add(new RunRadio("[a harmonic minor keys") { 
61               public void run() { 
62                   System.out.println(isSelected() + "set up a harmonic minor keys"); 
63               } 
64           } 
65           ); 
66           c.setLayout(new java.awt.GridLayout(1, 0)); 
67           cf.setSize(200, 200); 
68           cf.setVisible(true); 
69       } 
70    
71    
72   }