source: branches/libc-0.6/src/gcc/libjava/java/awt/Menu.java

Last change on this file was 1392, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r1391,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 9.9 KB
Line 
1/* Menu.java -- A Java AWT Menu
2 Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38
39package java.awt;
40
41import java.awt.peer.MenuPeer;
42import java.awt.peer.MenuItemPeer;
43import java.awt.peer.MenuComponentPeer;
44import java.io.Serializable;
45import java.util.Vector;
46import java.util.Enumeration;
47
48/**
49 * This class represents a pull down or tear off menu in Java's AWT.
50 *
51 * @author Aaron M. Renn ([email protected])
52 */
53public class Menu extends MenuItem implements MenuContainer, Serializable
54{
55
56/*
57 * Static Variables
58 */
59
60// Serialization Constant
61private static final long serialVersionUID = -8809584163345499784L;
62
63/*************************************************************************/
64
65/*
66 * Instance Variables
67 */
68
69/**
70 * @serial The actual items in the menu
71 */
72private Vector items = new Vector();
73
74/**
75 * @serial Flag indicating whether or not this menu is a tear off
76 */
77private boolean isTearOff;
78
79/**
80 * @serial Indicates whether or not this is a help menu.
81 */
82private boolean isHelpMenu;
83
84// From the serialization spec. FIXME: what should it be?
85private int menuSerializedDataVersion;
86
87static final MenuItem separator = new MenuItem("-");
88
89/*************************************************************************/
90
91/*
92 * Constructors
93 */
94
95/**
96 * Initializes a new instance of <code>Menu</code> with no label and that
97 * is not a tearoff;
98 *
99 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
100 */
101public
102Menu()
103{
104}
105
106/*************************************************************************/
107
108/**
109 * Initializes a new instance of <code>Menu</code> that is not a tearoff and
110 * that has the specified label.
111 *
112 * @param label The menu label.
113 *
114 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
115 */
116public
117Menu(String label)
118{
119 this(label, false);
120}
121
122/*************************************************************************/
123
124/**
125 * Initializes a new instance of <code>Menu</code> with the specified
126 * label and tearoff status.
127 *
128 * @param label The label for this menu
129 * @param isTearOff <code>true</code> if this menu is a tear off menu,
130 * <code>false</code> otherwise.
131 *
132 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
133 */
134public
135Menu(String label, boolean isTearOff)
136{
137 super(label);
138
139 this.isTearOff = isTearOff;
140
141 if (label.equals("Help"))
142 isHelpMenu = true;
143
144 if (GraphicsEnvironment.isHeadless())
145 throw new HeadlessException ();
146}
147
148/*************************************************************************/
149
150/*
151 * Instance Methods
152 */
153
154/**
155 * Tests whether or not this menu is a tearoff.
156 *
157 * @return <code>true</code> if this menu is a tearoff, <code>false</code>
158 * otherwise.
159 */
160public boolean
161isTearOff()
162{
163 return(isTearOff);
164}
165
166/*************************************************************************/
167
168/**
169 * Returns the number of items in this menu.
170 *
171 * @return The number of items in this menu.
172 */