MCPcopy Create free account
hub / github.com/DuGuQiuBai/Java / main

Method main

day25/code/day25_Frame/src/cn/itcast_07/MenuDemo2.java:22–111  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

20 */
21public class MenuDemo2 {
22 public static void main(String[] args) {
23 // �����������
24 final Frame f = new Frame("�༶�˵�");
25 // ��������
26 f.setBounds(500, 250, 400, 300);
27
28 // �����˵���
29 MenuBar mb = new MenuBar();
30 // �����˵�
31 Menu m1 = new Menu("�ļ�");
32 Menu m2 = new Menu("��������");
33 // �����˵���
34 final MenuItem mi1 = new MenuItem("�ú�ѧϰ");
35 final MenuItem mi2 = new MenuItem("��������");
36 MenuItem mi3 = new MenuItem("�ָ�����");
37 MenuItem mi4 = new MenuItem("�򿪼��±�");
38 MenuItem mi5 = new MenuItem("�˳�ϵͳ");
39
40 // �˵��������
41 m2.add(mi1);
42 m2.add(mi2);
43 m2.add(mi3);
44
45 m1.add(m2);
46 m1.add(mi4);
47 m1.add(mi5);
48
49 mb.add(m1);
50
51 // ���ӵ�����
52 f.setMenuBar(mb);
53
54 // ��ȡ��ǰ�ı���
55 final String title = f.getTitle();
56
57 // ע���¼�
58 f.addWindowListener(new WindowAdapter() {
59 @Override
60 public void windowClosing(WindowEvent e) {
61 System.exit(0);
62 }
63 });
64
65 mi5.addActionListener(new ActionListener() {
66
67 @Override
68 public void actionPerformed(ActionEvent e) {
69 System.exit(0);
70 }
71 });
72
73 mi4.addActionListener(new ActionListener() {
74
75 @Override
76 public void actionPerformed(ActionEvent e) {
77 Runtime r = Runtime.getRuntime();
78 try {
79 r.exec("notepad");

Callers

nothing calls this directly

Calls 1

addMethod · 0.45

Tested by

no test coverage detected