OSDN Git Service

* java/awt/MenuItem.java (paramString): Now protected.
[pf3gnuchains/gcc-fork.git] / libjava / java / awt / MenuComponent.java
1 /* Copyright (C) 1999, 2000  Free Software Foundation
2
3    This file is part of libgcj.
4
5 This software is copyrighted work licensed under the terms of the
6 Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
7 details.  */
8
9 package java.awt;
10
11 /* Status: partially complete, untested. */
12
13 public abstract class MenuComponent implements java.io.Serializable
14 {
15   // Fields from the serialization spec. Decalare others "transient".
16   Font font;
17   String name;
18   boolean nameExplicitlySet;
19   boolean newEventsOnly;
20   //AccessibleContext accessibleContext;
21   
22   transient MenuContainer parent;
23   transient java.awt.peer.MenuComponentPeer peer;
24
25   public MenuComponent()
26   {
27   }
28
29   public String getName()
30   {
31     if (name == null && !nameExplicitlySet)
32       name = generateName();
33     return name;
34   }
35   
36   /** Subclasses should override this to generate unique names like 
37     * "menuitem0".
38     */
39   String generateName()
40   {
41     // MenuComponent is abstract.
42     return null;
43   }
44
45   public void setName(String name)
46   {
47     nameExplicitlySet = true;
48     this.name = name;
49   }
50
51   public MenuContainer getParent()
52   {
53     return parent;
54   }
55
56   /** @deprecated Don't use this. */
57   public java.awt.peer.MenuComponentPeer getPeer()
58   {
59     return peer;
60   }
61
62   public Font getFont()
63   {
64     return font;
65   }
66
67   public void setFont(Font f)
68   {
69     this.font = f;
70   }
71
72   public void removeNotify()
73   {
74     if (peer != null)
75       peer.dispose ();
76     peer = null;
77   }
78
79   /** @deprecated Replaced by dispatchEvent(AWTEvent) */
80   public boolean postEvent(Event evt)
81   {
82     return false;
83   }
84
85   public final void dispatchEvent(AWTEvent e)
86   {
87     // FIXME
88     dispatchEventImpl(e);
89   }
90   
91   void dispatchEventImpl(AWTEvent e)
92   {
93     // This is overridden by subclasses that support events.
94   }
95
96   protected void processEvent(AWTEvent e)
97   {
98     // Nothing to do here? This is be overridden by subclasses that 
99     // support events.
100   }
101
102   protected String paramString()
103   {
104     return name;
105   }
106
107   public String toString()
108   {
109     return this.getClass().getName() + "[" + paramString() + "]";
110   }
111
112   protected final Object getTreeLock()
113   {
114     // FIXME: figure out how the tree lock works.
115     return null;
116   }
117
118   // Accessibility API not yet implemented.
119   // public AccessibleContext getAccessibleContext()
120 }