aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/Container.java
blob: 84840246b755af578153d5eb2e110fe5ca84425f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/* Copyright (C) 1999, 2000  Free Software Foundation

   This file is part of libjava.

This software is copyrighted work licensed under the terms of the
Libjava License.  Please consult the file "LIBJAVA_LICENSE" for
details.  */

package java.awt;

import java.awt.event.*;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.EventListener;

/* A very incomplete placeholder. */

public abstract class Container extends Component
{
  /* Serialized fields from the serialization spec. */
  int ncomponents;
  Component[] component;
  LayoutManager layoutMgr;
  /* LightweightDispatcher dispatcher; */ // wtf?
  Dimension maxSize;
  int containerSerializedDataVersion;

  /* Anything else is non-serializable, and should be declared "transient". */
  transient ContainerListener containerListener;  
  
  public Container()
  {
  }

  public int getComponentCount()
  {
    return ncomponents;
  }

  /** @deprecated Use getComponentCount() instead. */
  public int countComponents()
  {
    return ncomponents;
  }

  public Component getComponent (int n)
  {
    if (n < 0 || n >= ncomponents)
      throw new ArrayIndexOutOfBoundsException("no such component");
    return component[n];
  }

  public Component[] getComponents()
  {
    Component[] result = new Component[ncomponents];
    if (ncomponents > 0)
      System.arraycopy(component, 0, result, 0, ncomponents);
    return result;
  }

  public Insets getInsets()
  {
    // FIXME
    return null;
  }
  
  /** @deprecated Use getInsets() instead. */
  public Insets insets()
  {
    return getInsets();
  }
  
  public Component add(Component comp)
  {
    // FIXME
    return null;
  }
  
  public Component add(String name, Component comp)
  {
    // FIXME
    return null;
  }

  public Component add(Component comp, int index)
  {
    // FIXME
    return null;
  }

  public void add(Component comp, Object constraints)
  {
    // FIXME
  }

  public void add(Component comp, Object constraints, int index)
  {
    // FIXME
  }

  protected void addImpl(Component comp, Object constraints, int index)
  {
    // FIXME
  }

  public void remove(int index)
  {
    // FIXME
  }

  public void remove(Component comp)
  {
    // FIXME
  }

  public void removeAll()
  {
    // FIXME
  }

  public LayoutManager getLayout()
  {
    return layoutMgr;
  }
  
  public void setLayout(LayoutManager mgr)
  {
    layoutMgr = mgr;
    // FIXME
  }
  
  public void doLayout()
  {
    // FIXME
  }

  /** @deprecated Use doLayout() instead. */
  public void layout()
  {
    doLayout();
  }

  public void invalidate()
  {
    // FIXME
  }

  public void validate()
  {
    // FIXME
  }

  protected void validateTree()
  {
    // FIXME
  }

  public void setFont(Font f)
  {
    // FIXME
  }

  public Dimension getPreferredSize()
  {
    // FIXME
    return null;
  }
  
  /** @deprecated Use getPreferredSize() instead */
  public Dimension preferredSize()
  {
    return getPreferredSize();
  }
  
  public Dimension getMinimumSize()
  {
    // FIXME
    return null;
  }
  
  /** @deprecated Use getMinimumSize() instead */
  public Dimension minimumSize()
  {
    return getMinimumSize();
  }
  
  public Dimension getMaximumSize()
  {
    // FIXME
    return null;    
  }
  
  public float getAlignmentX()
  {
    // FIXME
    return 0;
  }

  public float getAlignmentY()
  {
    // FIXME
    return 0;
  }

  public void paint(Graphics g)
  {
    // FIXME
  }

  public void update(Graphics g)
  {
    // FIXME
  }

  public void print(Graphics g)
  {
    // FIXME
  }

  public void paintComponents(Graphics g)
  {
    // FIXME
  }

  public void printComponents(Graphics g)
  {
    // FIXME
  }
  
  void dispatchEventImpl(AWTEvent e)
  {
    if ((e.id <= ContainerEvent.CONTAINER_LAST
             && e.id >= ContainerEvent.CONTAINER_FIRST)
	&& (containerListener != null
	    || (eventMask & AWTEvent.CONTAINER_EVENT_MASK) != 0))
      processEvent(e); 
    else super.dispatchEventImpl(e);
  }  

  public void addContainerListener(ContainerListener l)
  {
    containerListener = (ContainerListener) 
                          AWTEventMulticaster.add(containerListener, l);
  }

  public void removeContainerListener(ContainerListener l)
  {
    containerListener = (ContainerListener)
			  AWTEventMulticaster.remove(containerListener, l);
  }

  /** @since 1.3 */
  public EventListener[] getListeners(Class listenerType)
  {
    if (listenerType == ContainerListener.class)
      return getListenersImpl(listenerType, containerListener);
    else return super.getListeners(listenerType);
  }
  
  protected void processEvent(AWTEvent e)
  {
    if (e instanceof ContainerEvent)
      processContainerEvent((ContainerEvent) e);
    else super.processEvent(e);
  }
  
  protected void processContainerEvent(ContainerEvent e)
  {
    if (componentListener == null)
      return;
    switch (e.id)
      {
	case ContainerEvent.COMPONENT_ADDED:
	  containerListener.componentAdded(e);
	break;

	case ContainerEvent.COMPONENT_REMOVED:
	  containerListener.componentRemoved(e);
	break;    
      }
  }

  /** @deprecated */
  public void deliverEvent(Event e)
  {
  }
  
  public Component getComponentAt(int x, int y)
  {
    // FIXME
    return null;
  }

  /** @deprecated Use getComponentAt() instead */
  public Component locate(int x, int y)
  {
    return getComponentAt(x, y);
  }

  public Component getComponentAt(Point p)
  {
    return getComponentAt(p.x, p.y);
  }

  public Component findComponentAt(int x, int y)
  {
    // FIXME
    return null;
  }

  public Component findComponentAt(Point p)
  {
    return findComponentAt(p.x, p.y);
  }

  public void addNotify ()
  {
    for (int i = ncomponents;  --i >= 0; )
      component[i].addNotify();
  }  

  public void removeNotify()
  {
    // FIXME
  }

  public boolean isAncestorOf (Component comp)
  {
    for (;;)
      {
	if (comp == null)
	  return false;
	if (comp == this)
	  return true;
	comp = comp.getParent();
      }
  }

  protected String paramString()
  {
    return "FIXME";
  }
  
  public void list(PrintStream out, int indent)
  {
    // FIXME  
  }
  
  public void list(PrintWriter out, int indent)
  {
    // FIXME  
  }
}