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

1    package gui.run; 
2     
3    import gui.ClosableJFrame; 
4     
5    import javax.swing.*; 
6    import java.awt.Container; 
7    import java.awt.GridLayout; 
8     
9     
10   public class RunTabbedFrame 
11           extends ClosableJFrame { 
12       Container c = getContentPane(); 
13       RunTabController rtc; 
14       JTabbedPane jtp 
15               = new JTabbedPane(); 
16    
17       class CheckBoxPanel 
18               extends JPanel { 
19           RunTabController rtc; 
20    
21           CheckBoxPanel( 
22                   RunTabController _rtc) { 
23               super(false); 
24               rtc = _rtc; 
25    
26               add(new RunCheckBox("Check #[1") { 
27                   public void run() { 
28                       rtc.println( 
29                               "First Check Box!"); 
30                   } 
31               }); 
32               add(new RunCheckBox("Check #[2") { 
33                   public void run() { 
34                       rtc.println("check #2"); 
35                   } 
36               }); 
37               add(new RunCheckBox("Check #[3") { 
38                   public void run() { 
39                       rtc.println("check #3"); 
40                   } 
41               }); 
42    
43           } 
44       } 
45    
46       class MenuBarPanel 
47               extends javax.swing.JPanel { 
48           RunTabController rtc; 
49           JMenuBar bar 
50                   = new JMenuBar(); 
51           JMenu menu 
52                   = new javax.swing.JMenu( 
53                           "Checkable"); 
54    
55           MenuBarPanel( 
56                   RunTabController _rtc) { 
57               super(false); 
58               rtc = _rtc; 
59               bar.add(menu); 
60               menu.add(new RunCheckBoxMenuItem( 
61                       "[Top Check{alt shift T}") { 
62                   public void run() { 
63                       rtc.println("topCheck!"); 
64                   } 
65               }); 
66               menu.add(new RunCheckBoxMenuItem( 
67                       "[Check Me{alt shift C}") { 
68                   public void run() { 
69                       rtc.println( 
70                               "Check box menu item!!"); 
71                   } 
72               }); 
73               menu.add(new RunCheckBoxMenuItem( 
74                       "[Type me{typed A}") { 
75                   public void run() { 
76                       rtc.println( 
77                               "Check box menu item!!"); 
78                   } 
79               }); 
80               add(bar); 
81           } 
82       } 
83    
84       class RunButtonPanel 
85               extends javax.swing.JPanel { 
86           gui.run.RunTabController rtc; 
87    
88           RunButtonPanel( 
89                   gui.run.RunTabController rtc) { 
90               super(false); 
91               this.rtc = rtc; 
92               add(new RunButton("[Left") { 
93                   public void run() { 
94                       System.out.println(getText()); 
95                   } 
96               }); 
97               add(new RunButton("[Right") { 
98                   public void run() { 
99                       System.out.println(getText()); 
100                  } 
101              }); 
102              add(new RunButton("[Quit") { 
103                  public void run() { 
104                      setVisible(false); 
105                  } 
106              }); 
107          } 
108      } 
109   
110      public RunTabbedFrame(RunTabController rtc) { 
111          super("gui.run tab"); 
112          this.rtc = rtc; 
113          setSize(200, 200); 
114          jtp.addTab("[Button Panel", 
115                     null, 
116                     new RunButtonPanel(rtc), 
117                     "Quit Button is here!"); 
118   
119          jtp.addTab("[CheckBox Panel", 
120                     null, 
121                     new CheckBoxPanel(rtc), 
122                     "Examples of JCheckBox"); 
123   
124          jtp.addTab("[Menu Bar Panel", null, 
125                     new MenuBarPanel(rtc), 
126                     "Examples of JMenuBar"); 
127   
128          jtp.addTab("[Label Panel", null, 
129                     new LabelPanel(), 
130                     "Examples of JLabel"); 
131          ShortcutUtils.addShortcut(jtp); 
132          c.add(jtp); 
133          c.setLayout(new GridLayout(1, 1)); 
134          setVisible(true); 
135      } 
136   
137      class LabelPanel extends javax.swing.JPanel { 
138          LabelPanel() { 
139              add(new JLabel("I'm Label 1     ")); 
140              add(new JLabel("I'm Label 2     ")); 
141              add(new JLabel("I'm Label 3")); 
142          } 
143      } 
144  }