Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/integralsource/monsoon/jfc/MenuBar.java


1   /*
2    *  Copyright (c) 2001 John Keyes
3    *
4    *  This program is free software; you can redistribute it and/or
5    *  modify it under the terms of the GNU General Public License
6    *  as published by the Free Software Foundation; either version 2
7    *  of the License, or (at your option) any later version.
8    *
9    *  This program is distributed in the hope that it will be useful,
10   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   *  GNU General Public License for more details.
13   *
14   *  You should have received a copy of the GNU General Public License
15   *  along with this program; if not, write to:
16   *  Free Software Foundation, Inc., 59 Temple Place - Suite 330, 
17   *  Boston, MA  02111-1307, USA. 
18   *
19   *  $Id: MenuBar.java,v 1.3 2001/08/06 20:49:21 jbjk Exp $
20   */
21  package org.integralsource.monsoon.jfc;
22  
23  /**
24   * The application menubar
25   */
26  public class MenuBar extends javax.swing.JMenuBar {
27  
28      javax.swing.JMenuItem _quit = new javax.swing.JMenuItem("Quit");
29      javax.swing.JMenuItem _newitem = new javax.swing.JMenuItem("New Item");
30      javax.swing.JMenuItem _viewitem = new javax.swing.JMenuItem("View Item");
31      javax.swing.JMenuItem _deleteitem = new javax.swing.JMenuItem("Delete Item");
32      javax.swing.JMenuItem _newlist = new javax.swing.JMenuItem("New List");
33      javax.swing.JMenuItem _savelist = new javax.swing.JMenuItem("Save List");
34      javax.swing.JMenuItem _deletelist = new javax.swing.JMenuItem("Delete List");
35      javax.swing.JMenuItem _about = new javax.swing.JMenuItem("About");
36  
37      javax.swing.JMenu _file = new javax.swing.JMenu("File");
38      javax.swing.JMenu _help = new javax.swing.JMenu("Help");
39      
40  
41      // the action listener
42      java.awt.event.ActionListener _listener;
43  
44      public MenuBar(java.awt.event.ActionListener listener) {
45    super();
46  
47    // initialise the action listener
48    _listener = listener;
49  
50    // initialise the menu components
51    __init();
52      }
53      
54      /**
55       * Initialise the menu components
56       */
57      private void __init() {
58  
59    __addMenuItem(_file,_newitem,"add");
60    __addMenuItem(_file,_deleteitem,"delete");
61    __addMenuItem(_file,_viewitem,"view");
62    _file.addSeparator();
63    __addMenuItem(_file,_newlist,"newlist");
64    __addMenuItem(_file,_savelist,"savelist");
65    __addMenuItem(_file,_deletelist,"deletelist");
66    _file.addSeparator();
67    __addMenuItem(_file,_quit,"quit");
68    __addMenuItem(_help,_about,"about");
69  
70    _file.setFont(_font);
71    _help.setFont(_font);
72    add(_file);  
73    add(_help);
74      }
75  
76      private void __addMenuItem(javax.swing.JMenu menu,
77               javax.swing.JMenuItem item,
78               java.lang.String command) {
79    item.setActionCommand(command);
80    item.addActionListener(_listener);
81    item.setFont(_font);
82    menu.add(item);
83      }
84  
85      private javax.swing.border.Border _border 
86    = new javax.swing.border.EmptyBorder(4,4,4,4);
87  
88      private java.awt.Color _default = new java.awt.Color(204,204,204);
89      // font for menu text
90      private java.awt.Font _font = new java.awt.Font("Arial",java.awt.Font.PLAIN,12);
91  }
92