FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / awt / MenuComponent.java
blob09c25c9d1af59f64995b4529080349381bd1dfc3
1 /* MenuComponent.java -- Superclass of all AWT menu components
2 Copyright (C) 1999, 2000, 2002 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;
43 // FIXME: Java 1.0 event model unimplemented
45 /**
46 * This is the superclass of all non-menu AWT widgets.
48 * @author Aaron M. Renn (arenn@urbanophile.com)
50 public abstract class MenuComponent implements java.io.Serializable
54 * Static Variables
57 // Serialization Constant
58 private static final long serialVersionUID = -4536902356223894379L;
60 /*************************************************************************/
63 * Instance Variables
66 // FIXME: missing serialized fields `nameExplicitlySet',
67 // `newEventsOnly', and `accessibleContext'.
69 // The font for this component
70 private Font font;
72 // The name of the component
73 private String name;
75 // The parent of this component
76 transient MenuContainer parent;
78 // The native peer for this componet
79 transient MenuComponentPeer peer;
81 // The synchronization locking object for this component
82 private transient Object tree_lock = this;
84 // The toolkit for this object
85 private static transient Toolkit toolkit = Toolkit.getDefaultToolkit();
87 /*************************************************************************/
90 * Constructors
93 /**
94 * Default constructor for subclasses.
96 * @exception HeadlessException If GraphicsEnvironment.isHeadless() is true.
98 public
99 MenuComponent()
101 if (GraphicsEnvironment.isHeadless())
102 throw new HeadlessException ();
105 /*************************************************************************/
108 * Instance Methods
112 * Returns the font in use for this component.
114 * @return The font for this component.
116 public Font
117 getFont()
119 return(font);
122 /*************************************************************************/
125 * Sets the font for this component to the specified font.
127 * @param font The new font for this component.
129 public void
130 setFont(Font font)
132 this.font = font;
135 /*************************************************************************/
138 * Returns the name of this component.
140 * @return The name of this component.
142 public String
143 getName()
145 return(name);
148 /*************************************************************************/
151 * Sets the name of this component to the specified name.
153 * @param name The new name of this component.
155 public void
156 setName(String name)
158 this.name = name;
161 /*************************************************************************/
164 * Returns the parent of this component.
166 * @return The parent of this component.
168 public MenuContainer
169 getParent()
171 return(parent);
174 /*************************************************************************/
176 // Sets the parent of this component.
177 final void
178 setParent(MenuContainer parent)
180 this.parent = parent;
183 /*************************************************************************/
186 * Returns the native windowing system peer for this component.
188 * @return The peer for this component.
190 public MenuComponentPeer
191 getPeer()
193 return(peer);
196 /*************************************************************************/
198 // Sets the peer for this component.
199 final void
200 setPeer(MenuComponentPeer peer)
202 this.peer = peer;
205 /*************************************************************************/
208 * Destroys this component's native peer
210 public void
211 removeNotify()
213 if (peer != null)
214 peer.dispose();
215 peer = null;
218 /*************************************************************************/
221 * Returns the toolkit in use for this component.
223 * @return The toolkit for this component.
225 final Toolkit
226 getToolkit()
228 return(toolkit);
231 /*************************************************************************/
234 * Returns the object used for synchronization locks on this component
235 * when performing tree and layout functions.
237 * @return The synchronization lock for this component.
239 protected final Object
240 getTreeLock()
242 return(tree_lock);
245 /*************************************************************************/
247 // The sync lock object for this component.
248 final void
249 setTreeLock(Object tree_lock)
251 this.tree_lock = tree_lock;
254 /*************************************************************************/
257 * AWT 1.0 event dispatcher.
259 * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
261 public boolean
262 postEvent(Event event)
264 return(false);
267 /*************************************************************************/
270 * Sends this event to this component or a subcomponent for processing.
272 * @param event The event to dispatch
274 public final void
275 dispatchEvent(AWTEvent event)
277 // See comment in Component.dispatchEvent().
278 dispatchEventImpl(event);
281 void
282 dispatchEventImpl(AWTEvent e)
284 // This is overridden by subclasses that support events.
287 /*************************************************************************/
290 * Processes the specified event. In this class, this method simply
291 * calls one of the more specific event handlers.
293 * @param event The event to process.
295 protected void
296 processEvent(AWTEvent event)
300 /*************************************************************************/
303 * Returns a string representation of this component.
305 * @return A string representation of this component
307 public String
308 toString()
310 return this.getClass().getName() + "[" + paramString() + "]";
313 /*************************************************************************/
316 * Returns a debugging string for this component
318 protected String
319 paramString()
321 return "name=" + getName();
324 // Accessibility API not yet implemented.
325 // public AccessibleContext getAccessibleContext()
327 } // class Component