2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / java / awt / MenuComponent.java
blobccf2b4974430c73698bf526144c21e4a9e95d853
1 /* MenuComponent.java -- Superclass of all AWT menu components
2 Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package java.awt;
41 import java.awt.peer.MenuComponentPeer;
42 import java.io.Serializable;
44 // FIXME: Java 1.0 event model unimplemented
46 /**
47 * This is the superclass of all non-menu AWT widgets.
49 * @author Aaron M. Renn (arenn@urbanophile.com)
51 public abstract class MenuComponent implements Serializable
55 * Static Variables
58 // Serialization Constant
59 private static final long serialVersionUID = -4536902356223894379L;
61 /*************************************************************************/
64 * Instance Variables
67 // FIXME: missing serialized fields `nameExplicitlySet',
68 // `newEventsOnly', and `accessibleContext'.
70 // The font for this component
71 private Font font;
73 // The name of the component
74 private String name;
76 // The parent of this component
77 transient MenuContainer parent;
79 // The native peer for this componet
80 transient MenuComponentPeer peer;
82 // The synchronization locking object for this component
83 private transient Object tree_lock = this;
85 // The toolkit for this object
86 private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();
88 /*************************************************************************/
91 * Constructors
94 /**
95 * Default constructor for subclasses.
97 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
99 public
100 MenuComponent()
102 if (GraphicsEnvironment.isHeadless())
103 throw new HeadlessException ();
106 /*************************************************************************/
109 * Instance Methods
113 * Returns the font in use for this component.
115 * @return The font for this component.
117 public Font
118 getFont()
120 return(font);
123 /*************************************************************************/
126 * Sets the font for this component to the specified font.
128 * @param font The new font for this component.
130 public void
131 setFont(Font font)
133 this.font = font;
136 /*************************************************************************/
139 * Returns the name of this component.
141 * @return The name of this component.
143 public String
144 getName()
146 return(name);
149 /*************************************************************************/
152 * Sets the name of this component to the specified name.
154 * @param name The new name of this component.
156 public void
157 setName(String name)
159 this.name = name;
162 /*************************************************************************/
165 * Returns the parent of this component.
167 * @return The parent of this component.
169 public MenuContainer
170 getParent()
172 return(parent);
175 /*************************************************************************/
177 // Sets the parent of this component.
178 final void
179 setParent(MenuContainer parent)
181 this.parent = parent;
184 /*************************************************************************/
187 * Returns the native windowing system peer for this component.
189 * @return The peer for this component.
191 * @deprecated
193 public MenuComponentPeer
194 getPeer()
196 return(peer);
199 /*************************************************************************/
201 // Sets the peer for this component.
202 final void
203 setPeer(MenuComponentPeer peer)
205 this.peer = peer;
208 /*************************************************************************/
211 * Destroys this component's native peer
213 public void
214 removeNotify()
216 if (peer != null)
217 peer.dispose();
218 peer = null;
221 /*************************************************************************/
224 * Returns the toolkit in use for this component.
226 * @return The toolkit for this component.
228 final Toolkit
229 getToolkit()
231 return(toolkit);
234 /*************************************************************************/
237 * Returns the object used for synchronization locks on this component
238 * when performing tree and layout functions.
240 * @return The synchronization lock for this component.
242 protected final Object
243 getTreeLock()
245 return(tree_lock);
248 /*************************************************************************/
250 // The sync lock object for this component.
251 final void
252 setTreeLock(Object tree_lock)
254 this.tree_lock = tree_lock;
257 /*************************************************************************/
260 * AWT 1.0 event dispatcher.
262 * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
264 public boolean
265 postEvent(Event event)
267 return(false);
270 /*************************************************************************/
273 * Sends this event to this component or a subcomponent for processing.
275 * @param event The event to dispatch
277 public final void
278 dispatchEvent(AWTEvent event)
280 // See comment in Component.dispatchEvent().
281 dispatchEventImpl(event);
284 void
285 dispatchEventImpl(AWTEvent e)
287 // This is overridden by subclasses that support events.
290 /*************************************************************************/
293 * Processes the specified event. In this class, this method simply
294 * calls one of the more specific event handlers.
296 * @param event The event to process.
298 protected void
299 processEvent(AWTEvent event)
303 /*************************************************************************/
306 * Returns a string representation of this component.
308 * @return A string representation of this component
310 public String
311 toString()
313 return this.getClass().getName() + "[" + paramString() + "]";
316 /*************************************************************************/
319 * Returns a debugging string for this component
321 protected String
322 paramString()
324 return "name=" + getName();
327 // Accessibility API not yet implemented.
328 // public AccessibleContext getAccessibleContext()
330 } // class Component