Yurttas/PL/OOL/Java/F/05/02/02/07/Menu02.java

 1/**
 2 *  Copyright(C) 1998
 3 *  All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4 *
 5 *  Permission to use, copy, modify, and distribute this
 6 *  software and its documentation for EDUCATIONAL purposes
 7 *  and without fee is hereby granted provided that this
 8 *  copyright notice appears in all copies.
 9 *
10 *  @date   : January 1, 1998.
11 *  @authorĀ : Salih Yurttas.
12 */
13
14
15import java.awt.*;
16
17import java.awt.event.*;
18
19public class Menu02 extends Frame
20		    implements ActionListener {
21
22  private Menu m1 = new Menu("Search");
23
24  private Menu m2 = new Menu("Sort");
25
26  public Menu02() {
27    super("Menu02");
28    MenuBar mb = new MenuBar();
29
30    // Add item to menu.
31    m1.add("Linear");
32
33    // Add listener for menu
34    m1.addActionListener(this);
35
36    // Add item to menu.
37    m1.add("Binary");
38
39    // Add menu to menu bar
40    mb.add(m1);
41
42    // Set menu bar on frame.
43    setMenuBar(mb);
44
45    // Add item to menu.
46    m2.add("Bubble");
47
48    // Add listener for menu
49    m2.addActionListener(this);
50
51    // Add item to menu.
52    m2.add("Quick");
53
54    // Add menu to menu bar
55    mb.add(m2);
56
57    setSize(320, 160);
58    show();
59  }
60
61  // Action handler for menu
62  public void actionPerformed(ActionEvent evt) {
63    System.out.println(evt.getActionCommand());
64  }
65
66  static public void main(String[] args) {
67    new Menu02();
68  }
69
70}