source: trunk/gcc/libjava/java/awt/MenuComponent.java

Last change on this file was 1392, checked in by bird, 21 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: 7.4 KB
Line 
1/* MenuComponent.java -- Superclass of all AWT menu components
2 Copyright (C) 1999, 2000, 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.MenuComponentPeer;
42
43// FIXME: Java 1.0 event model unimplemented
44
45/**
46 * This is the superclass of all non-menu AWT widgets.
47 *
48 * @author Aaron M. Renn (arenn@urbanophile.com)
49 */
50public abstract class MenuComponent implements java.io.Serializable
51{
52
53/*
54 * Static Variables
55 */
56
57// Serialization Constant
58private static final long serialVersionUID = -4536902356223894379L;
59
60/*************************************************************************/
61
62/*
63 * Instance Variables
64 */
65
66 // FIXME: missing serialized fields `nameExplicitlySet',
67 // `newEventsOnly', and `accessibleContext'.
68
69// The font for this component
70private Font font;
71
72// The name of the component
73private String name;
74
75// The parent of this component
76transient MenuContainer parent;
77
78// The native peer for this componet
79transient MenuComponentPeer peer;
80
81// The synchronization locking object for this component
82private transient Object tree_lock = this;
83
84// The toolkit for this object
85private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();
86
87/*************************************************************************/
88
89/*
90 * Constructors
91 */
92
93/**
94 * Default constructor for subclasses.
95 *
96 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
97 */
98protected
99MenuComponent()
100{
101 if (GraphicsEnvironment.isHeadless())
102 throw new HeadlessException ();
103}
104
105/*************************************************************************/
106
107/*
108 * Instance Methods
109 */
110
111/**
112 * Returns the font in use for this component.
113 *
114 * @return The font for this component.
115 */
116public Font
117getFont()
118{
119 return(font);
120}
121
122/*************************************************************************/
123
124/**
125 * Sets the font for this component to the specified font.
126 *
127 * @param font The new font for this component.
128 */
129public void
130setFont(Font font)
131{
132 this.font = font;
133}
134
135/*************************************************************************/
136
137/**
138 * Returns the name of this component.
139 *
140 * @return The name of this component.
141 */
142public String
143getName()
144{
145 return(name);
146}
147
148/*************************************************************************/
149
150/**
151 * Sets the name of this component to the specified name.
152 *
153 * @param name The new name of this component.
154 */
155public void
156setName(String name)
157{
158 this.name = name;
159}
160
161/*************************************************************************/
162
163/**
164 * Returns the parent of this component.
165 *
166 * @return The parent of this component.
167 */
168public MenuContainer
169getParent()
170{
171 return(parent);
172}
173
174/*************************************************************************/
175
176// Sets the parent of this component.
177final void
178setParent(MenuContainer parent)
179{
180 this.parent = parent;
181}
182
183/*************************************************************************/
184
185/**
186 * Returns the native windowing system peer for this component.
187 *
188 * @return The peer for this component.
189 */
190public MenuComponentPeer
191getPeer()
192{
193 return(peer);
194}
195
196/*************************************************************************/
197
198// Sets the peer for this component.
199final void
200setPeer(MenuComponentPeer peer)
201{
202 this.peer = peer;
203}
204
205/*************************************************************************/
206
207/**
208 * Destroys this component's native peer
209 */
210public void
211removeNotify()
212{
213 if (peer != null)
214 peer.dispose();
215 peer = null;
216}
217
218/*************************************************************************/
219
220/**
221 * Returns the toolkit in use for this component.
222 *
223 * @return The toolkit for this component.
224 */
225final Toolkit
226getToolkit()
227{
228 return(toolkit);
229}
230
231/*************************************************************************/
232
233/**
234 * Returns the object used for synchronization locks on this component
235 * when performing tree and layout functions.
236 *
237 * @return The synchronization lock for this component.
238 */
239protected final Object
240getTreeLock()
241{
242 return(tree_lock);
243}
244
245/*************************************************************************/
246
247// The sync lock object for this component.
248final void
249setTreeLock(Object tree_lock)
250{
251 this.tree_lock = tree_lock;
252}
253
254/*************************************************************************/
255
256/**
257 * AWT 1.0 event dispatcher.
258 *
259 * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
260 */
261public boolean
262postEvent(Event event)
263{
264 return(false);
265}
266
267/*************************************************************************/
268
269/**
270 * Sends this event to this component or a subcomponent for processing.
271 *
272 * @param event The event to dispatch
273 */
274public final void
275dispatchEvent(AWTEvent event)
276{
277 // See comment in Component.dispatchEvent().
278 dispatchEventImpl(event);
279}
280
281void
282dispatchEventImpl(AWTEvent e)
283{
284 // This is overridden by subclasses that support events.
285}
286
287/*************************************************************************/
288
289/**
290 * Processes the specified event. In this class, this method simply
291 * calls one of the more specific event handlers.
292 *
293 * @param event The event to process.
294 */
295protected void
296processEvent(AWTEvent event)
297{
298}
299
300/*************************************************************************/
301
302/**
303 * Returns a string representation of this component.
304 *
305 * @return A string representation of this component
306 */
307public String
308toString()
309{
310 return this.getClass().getName() + "[" + paramString() + "]";
311}
312
313/*************************************************************************/
314
315/**
316 * Returns a debugging string for this component
317 */
318protected String
319paramString()
320{
321 return "name=" + getName();
322}
323
324// Accessibility API not yet implemented.
325// public AccessibleContext getAccessibleContext()
326
327} // class Component
Note: See TracBrowser for help on using the repository browser.