source: trunk/src/gcc/libjava/java/awt/MenuComponent.java@ 1389

Last change on this file since 1389 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.3 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 ([email protected])
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 */
96protected
97MenuComponent()
98{
99}
100
101/*************************************************************************/
102
103/*
104 * Instance Methods
105 */
106
107/**
108 * Returns the font in use for this component.
109 *
110 * @return The font for this component.
111 */
112public Font
113getFont()
114{
115 return(font);
116}
117
118/*************************************************************************/
119
120/**
121 * Sets the font for this component to the specified font.
122 *
123 * @param font The new font for this component.
124 */
125public void
126setFont(Font font)
127{
128 this.font = font;
129}
130
131/*************************************************************************/
132
133/**
134 * Returns the name of this component.
135 *
136 * @return The name of this component.
137 */
138public String
139getName()
140{
141 return(name);
142}
143
144/*************************************************************************/
145
146/**
147 * Sets the name of this component to the specified name.
148 *
149 * @param name The new name of this component.
150 */
151public void
152setName(String name)
153{
154 this.name = name;
155}
156
157/*************************************************************************/
158
159/**
160 * Returns the parent of this component.
161 *
162 * @return The parent of this component.
163 */
164public MenuContainer
165getParent()
166{
167 return(parent);
168}
169
170/*************************************************************************/
171
172// Sets the parent of this component.
173final void
174setParent(MenuContainer parent)
175{
176 this.parent = parent;
177}
178
179/*************************************************************************/
180
181/**
182 * Returns the native windowing system peer for this component.
183 *
184 * @return The peer for this component.
185 */
186public MenuComponentPeer
187getPeer()
188{
189 return(peer);
190}
191
192/*************************************************************************/
193
194// Sets the peer for this component.
195final void
196setPeer(MenuComponentPeer peer)
197{
198 this.peer = peer;
199}
200
201/*************************************************************************/
202
203/**
204 * Destroys this component's native peer
205 */
206public void
207removeNotify()
208{
209 if (peer != null)
210 peer.dispose();
211 peer = null;
212}
213
214/*************************************************************************/
215
216/**
217 * Returns the toolkit in use for this component.
218 *
219 * @return The toolkit for this component.
220 */
221final Toolkit
222getToolkit()
223{
224 return(toolkit);
225}
226
227/*************************************************************************/
228
229/**
230 * Returns the object used for synchronization locks on this component
231 * when performing tree and layout functions.
232 *
233 * @return The synchronization lock for this component.
234 */
235protected final Object
236getTreeLock()
237{
238 return(tree_lock);
239}
240
241/*************************************************************************/
242
243// The sync lock object for this component.
244final void
245setTreeLock(Object tree_lock)
246{
247 this.tree_lock = tree_lock;
248}
249
250/*************************************************************************/
251
252/**
253 * AWT 1.0 event dispatcher.
254 *
255 * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
256 */
257public boolean
258postEvent(Event event)
259{
260 return(false);
261}
262
263/*************************************************************************/
264
265/**
266 * Sends this event to this component or a subcomponent for processing.
267 *
268 * @param event The event to dispatch
269 */
270public final void
271dispatchEvent(AWTEvent event)
272{
273 // See comment in Component.dispatchEvent().
274 dispatchEventImpl(event);
275}
276
277void
278dispatchEventImpl(AWTEvent e)
279{
280 // This is overridden by subclasses that support events.
281}
282
283/*************************************************************************/
284
285/**
286 * Processes the specified event. In this class, this method simply
287 * calls one of the more specific event handlers.
288 *
289 * @param event The event to process.
290 */
291protected void
292processEvent(AWTEvent event)
293{
294}
295
296/*************************************************************************/
297
298/**
299 * Returns a string representation of this component.
300 *
301 * @return A string representation of this component
302 */
303public String
304toString()
305{
306 return this.getClass().getName() + "[" + paramString() + "]";
307}
308
309/*************************************************************************/
310
311/**
312 * Returns a debugging string for this component
313 */
314protected String
315paramString()
316{
317 return "name=" + getName();
318}
319
320// Accessibility API not yet implemented.
321// public AccessibleContext getAccessibleContext()
322
323} // class Component
Note: See TracBrowser for help on using the repository browser.