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

Revision as of 14:47, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="java" line start="1" enclose="div">/** * Copyright(C) 1998 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. * * P...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 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 Menu03 extends Frame
20		    implements ActionListener {
21
22  private Menu m1 = new Menu("Sort");
23
24  private Menu m2 = new Menu("Search");
25
26  public Menu03() {
27    super("Menu Example - 03");
28    MenuBar mb = new MenuBar();
29
30    // Add item to menu.
31    m1.add("BubbleSort");
32
33    // Add item to menu.
34    m1.add("QuickSort");
35
36    // Add listener for menu
37    m1.addActionListener(this);
38
39    // Add menu to menu bar
40    mb.add(m1);
41
42    // Add item to menu.
43    m2.add("LinearSearch");
44
45    // Add item to menu.
46    m2.add("BinarySearch");
47
48    // Add listener for menu
49    m2.addActionListener(this);
50
51    // Add menu to menu bar
52    mb.add(m2);
53
54    // Set menu bar on frame.
55    setMenuBar(mb);
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 Menu03();
68  }
69
70}