/Users/lyon/j4p/src/gui/keyboard/MnemonicMenu.java
|
1 package gui.keyboard;
2
3 //gui.keyboard.MnemonicMenu
4
5 public class MnemonicMenu extends
6 javax.swing.JMenu {
7 public MnemonicMenu() {
8 this("");
9 }
10
11
12 public MnemonicMenu(String s) {
13 this(s, false);
14 }
15
16 public MnemonicMenu(String s, boolean b) {
17 super(s, b);
18 if (s != null)
19 setMnemonic(s.charAt(0));
20 }
21
22 public static void main(String args[]) {
23 gui.ClosableJFrame cf = new gui.ClosableJFrame("RunMenuItem");
24 java.awt.Container c = cf.getContentPane();
25
26 javax.swing.JMenuBar mb =
27 new javax.swing.JMenuBar();
28 MnemonicMenu m = new MnemonicMenu("File");
29
30 gui.run.RunMenuItem om =
31 new gui.run.RunMenuItem("open...") {
32 public void run() {
33 System.out.println(getText());
34 }
35 };
36
37 gui.run.RunMenuItem sm = new
38 gui.run.RunMenuItem("save as...") {
39 public void run() {
40 System.out.println(getText());
41 }
42 };
43
44 m.add(om);
45 m.add(sm);
46
47 mb.add(m);
48 cf.setJMenuBar(mb);
49 c.setLayout(new java.awt.FlowLayout());
50 cf.setSize(200, 200);
51 cf.setVisible(true);
52 }
53
54 }