aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/Component.java
blob: 034390cb6c480a2cc5928cc2070eefabfd8f32ba (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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
/* Copyright (C) 1999, 2000, 2001, 2002  Free Software Foundation

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */

package java.awt;
import java.awt.event.*;
import java.awt.image.*;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.lang.reflect.*;
import java.util.EventListener;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Vector;
import java.awt.peer.ComponentPeer;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
// import javax.accessibility.AccessibleContext;

/**
  * The root of all evil.
  *
  * Status: Incomplete. The event dispatch mechanism is implemented. All 
  * other methods defined in the J2SE 1.3 API javadoc exist, but are mostly 
  * incomplete or only stubs; except for methods relating to the Drag and Drop, 
  * Input Method, and Accessibility frameworks: These methods are present but 
  * commented out.
  */
public abstract class Component implements ImageObserver, MenuContainer, 
					   java.io.Serializable
{
  /**
   * Constant returned by the <code>getAlignmentY</code> method to indicate
   * that the component wishes to be aligned to the bottom relative to
   * other components.
   */
  public static final float BOTTOM_ALIGNMENT = (float)1.0;

  /**
   * Constant returned by the <code>getAlignmentY</code> and 
   * <code>getAlignmentX</code> methods to indicate
   * that the component wishes to be aligned to the center relative to
   * other components.
   */
  public static final float CENTER_ALIGNMENT = (float)0.5;

  /**
   * Constant returned by the <code>getAlignmentY</code> method to indicate
   * that the component wishes to be aligned to the top relative to
   * other components.
   */
  public static final float TOP_ALIGNMENT = (float)0.0;

  /**
   * Constant returned by the <code>getAlignmentX</code> method to indicate
   * that the component wishes to be aligned to the right relative to
   * other components.
   */
  public static final float RIGHT_ALIGNMENT = (float)1.0;

  /**
   * Constant returned by the <code>getAlignmentX</code> method to indicate
   * that the component wishes to be aligned to the left relative to
   * other components.
   */
  public static final float LEFT_ALIGNMENT = (float)0.0;

  /* Make the treelock a String so that it can easily be identified
     in debug dumps. We clone the String in order to avoid a conflict in 
     the unlikely event that some other package uses exactly the same string
     as a lock object. */
  static Object treeLock = new String("AWT_TREE_LOCK");

  /* Serialized fields from the serialization spec. */
  // FIXME: Default values?
  int x;
  int y;
  int width;
  int height;
  Color foreground;
  Color background;
  Font font;
  Font peerFont;
  Cursor cursor;
  Locale locale;
  boolean visible = true; // default (except for Window)
  boolean enabled = true;
  boolean valid;
  boolean hasFocus;
  //DropTarget dropTarget;
  Vector popups;
  String name;
  boolean nameExplicitlySet;
  Dimension minSize;
  Dimension prefSize;
  boolean newEventsOnly;  
  long eventMask = AWTEvent.PAINT_EVENT_MASK;
  PropertyChangeSupport changeSupport;
  boolean isPacked;
  int componentSerializedDataVersion;
  /* AccessibleContext accessibleContext; */

  /* Anything else is non-serializable, and should be declared "transient". */
  transient Container parent;
  transient java.awt.peer.ComponentPeer peer;

  transient ComponentListener componentListener;
  transient FocusListener focusListener;
  transient KeyListener keyListener;
  transient MouseListener mouseListener;
  transient MouseMotionListener mouseMotionListener;
  transient InputMethodListener inputMethodListener;
  transient HierarchyListener hierarchyListener;
  transient HierarchyBoundsListener hierarchyBoundsListener;

  transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN;

  /**
   * Default constructor for subclasses.
   */
  protected Component()
  {
  }

  /**
   * Returns the name of this component.
   *
   * @return The name of this component.
   */
  public String getName()
  {
    if (name == null && !nameExplicitlySet)
      name = generateName();
    return name;
  }

  /**
   * Sets the name of this component to the specified name.
   *
   * @param name The new name of this component.
   */
  public void setName(String name)
  {
    nameExplicitlySet = true;
    this.name = name;
  }
  
  /** Subclasses should override this to return unique component names like 
    * "menuitem0".
    */
  String generateName()
  {
    // Component is abstract.
    return null;
  }

  /**
   * Returns the parent of this component.
   * 
   * @return The parent of this component.
   */
  public Container getParent()
  {
    return parent;  
  }

  // Sets the peer for this component.
  final void setPeer (ComponentPeer peer)
  {
    this.peer = peer;
  }

  /**
   * Returns the native windowing system peer for this component.
   *
   * @return The peer for this component.
   * @deprecated
   */
  // Classpath's Gtk peers rely on this.
  public java.awt.peer.ComponentPeer getPeer()
  {
    return peer;
  }

  // FIXME: java.awt.dnd classes not yet implemented
  /*
  public void setDropTarget(DropTarget dt)
  {
    this.dropTarget = dt;
  }
  
  public DropTarget getDropTarget()
  {
    return dropTarget;
  }
  */
  
  /** @since 1.3 */
  public GraphicsConfiguration getGraphicsConfiguration()
  {
    return getGraphicsConfigurationImpl();
  }

  /** Implementation method that allows classes such as Canvas and
      Window to override the graphics configuration without violating
      the published API. */
  GraphicsConfiguration getGraphicsConfigurationImpl()
  {
    if (peer != null)
      {
	GraphicsConfiguration config = peer.getGraphicsConfiguration();
	if (config != null)
	  return config;
      }

    if (parent != null)
      return parent.getGraphicsConfiguration();

    return null;
  }

  /**
   * Returns the object used for synchronization locks on this component
   * when performing tree and layout functions.
   *
   * @return The synchronization lock for this component.
   */
  public final Object getTreeLock()
  {
    return treeLock;
  }

  // The sync lock object for this component.
  final void setTreeLock(Object tree_lock)
  {
    this.treeLock = tree_lock;
  }

  /**
   * Returns the toolkit in use for this component.
   *
   * @return The toolkit for this component.
   */
  public Toolkit getToolkit()
  {
    if (peer != null)
      {
	Toolkit tk = peer.getToolkit();
	if (tk != null)
	  return tk;
      }
    if (parent != null)
      return parent.getToolkit ();
    return Toolkit.getDefaultToolkit ();
  }

  /**
   * Tests whether or not this component is valid.  A invalid component needs
   * to have its layout redone.
   *
   * @return <code>true</code> if this component is valid, <code>false</code>
   * otherwise.
   */
  public boolean isValid()
  {
    return valid;
  }
  
  /** @since 1.2 */
  public boolean isDisplayable()
  {
    if (parent != null)
      return parent.isDisplayable();
    return false;
  }

  /**
   * Tests whether or not this component is visible.
   *
   * @return <code>true</code> if the component is visible,
   * <code>false</code> otherwise.
   */
  public boolean isVisible()
  {
    return visible;
  }

  /**
   * Tests whether or not this component is actually being shown on
   * the screen.  This will be true if and only if it this component is
   * visible and its parent components are all visible.
   *
   * @return <code>true</code> if the component is showing on the screen,
   * <code>false</code> otherwise.
   */
  public boolean isShowing()
  {
    if (! visible || peer == null)
      return false;

    return parent == null ? true : parent.isShowing ();
  }

  /**
   * Tests whether or not this component is enabled.
   *
   * @return <code>true</code> if the component is enabled,
   * <code>false</code> otherwise.
   */
  public boolean isEnabled()
  {
    return enabled;
  }

  /**
   * Enables or disables this component.
   *
   * @param enabled <code>true</code> to enable this component, 
   * <code>false</code> to disable it.
   *
   * @deprecated Deprecated in favor of <code>setEnabled()</code>.
   */
  public void setEnabled(boolean b)
  {
    this.enabled = b;
    if (peer != null)
      peer.setEnabled(b);
  }

  /**
   * Enables this component.
   *
   * @deprecated Deprecated in favor of <code>setEnabled()</code>.
   */
  public void enable()
  {
    setEnabled(true);
  }

  /**
   * Enables or disables this component.
   *
   * @param enabled <code>true</code> to enable this component, 
   * <code>false</code> to disable it.
   *
   * @deprecated Deprecated in favor of <code>setEnabled()</code>.
   */
  public void enable(boolean b)
  {
    setEnabled(b);
  }

  /**
   * Disables this component.
   *
   * @deprecated Deprecated in favor of <code>setEnabled()</code>.
   */
  public void disable()
  {
    setEnabled(false);
  }

  public boolean isDoubleBuffered()
  {
    return false;
  }

  /** @since 1.2 */
  public void enableInputMethods(boolean enable)
  {
    // FIXME
  }

  /**
   * Makes this component visible or invisible.
   *
   * @param visible <code>true</code> to make this component visible,
   * </code>false</code> to make it invisible.
   * @specnote  Inspection by subclassing shows that Sun's implementation
   * calls show(boolean) which then calls show() or hide(). It is
   * the show() method that is overriden in subclasses like Window.
   * We do the same to preserve compatibility for subclasses.
   */
  public void setVisible(boolean b)
  {
    if (peer != null)
      peer.setVisible (b);
    this.visible = b;
  }

  /**
   * Makes this component visible on the screen.
   *
   * @deprecated Deprecated in favor of <code>setVisible()</code>.
   */
  public void show()
  {
    setVisible (true);
  }

  /**
   * Makes this component visible or invisible.
   *
   * @param visible <code>true</code> to make this component visible,
   * </code>false</code> to make it invisible.
   *
   * @deprecated Deprecated in favor of <code>setVisible()</code>.
   */
  public void show(boolean b)
  {
    setVisible (b);
  }

  /**
   * Hides this component so that it is no longer shown on the screen.
   *
   * @deprecated Deprecated in favor of <code>setVisible()</code>.
   */
  public void hide()
  {
    setVisible (false);
  }

  /**
   * Returns this component's foreground color.
   *
   * @return This component's foreground color.
   */
  public Color getForeground()
  {
    if (foreground != null)
      return foreground;
    if (parent != null)
      return parent.getForeground();
    return null;
  }

  /**
   * Sets this component's foreground color to the specified color.
   *
   * @param foreground_color The new foreground color.
   */
  public void setForeground(Color c)
  {
    if (peer != null)
      peer.setForeground(c);
    this.foreground = c;
  }

  /**
   * Returns this component's background color.
   *
   * @return the background color of the component. null may be
   * returned instead of the actual background color, if this
   * method is called before the component is added to the
   * component hierarchy.
   */
  public Color getBackground()
  {
    if (background != null)
      return background;
    if (parent != null)
      return parent.getBackground();
    return null;
  }

  /**
   * Sets this component's background color to the specified color.
   *
   * @param background_color The new background color
   */
  public void setBackground(Color c)
  {
    if (peer != null)
      peer.setBackground(c);
    this.background = c;
  }

  /**
   * Returns the font in use for this component.
   *
   * @return The font for this component.
   */
  public Font getFont()
  {
    if (font != null)
      return font;
    if (parent != null)
      return parent.getFont();
    return null;
  }

  /**
   * Sets the font for this component to the specified font.
   *
   * @param font The new font for this component.
   */
  public void setFont(Font f)
  {
    if (peer != null)
      peer.setFont(f);
    this.font = f;
  }

  /**
   * Returns the locale for this component.  If this component does not
   * have a locale, the locale of the parent component is returned.  If the
   * component has no parent, the system default locale is returned.
   *
   * @return The locale for this component.
   */
  public Locale getLocale() throws IllegalComponentStateException
  {
    if (locale != null)
      return locale;
    if (parent == null)
      throw new IllegalComponentStateException
        ("Component has no parent: Can not determine Locale");
    return parent.getLocale();
  }

  /**
   * Sets the locale for this component to the specified locale.
   *
   * @param locale The new locale for this component.
   */
  public void setLocale(Locale l)  
  {
    this.locale = l;

    /* new writing/layout direction perhaps, or make more/less
       room for localized text labels */
    invalidate();
  }

  /**
   * Returns the color model of the device this componet is displayed on.
   *
   * @return This object's color model.
   */
  public ColorModel getColorModel()
  {
    GraphicsConfiguration config = getGraphicsConfiguration();

    if (config != null)
      return config.getColorModel();

    return getToolkit().getColorModel();    
  }

  /**
   * Returns the location of this component's top left corner relative to
   * its parent component.
   *
   * @return The location of this component.
   */
  public Point getLocation()
  {
    return new Point(x, y);
  }

  /**
   * Returns the location of this component's top left corner in screen
   * coordinates.
   *
   * @return The location of this component in screen coordinates.
   */
  public Point getLocationOnScreen()
  {
    if (! isShowing ())
      throw new IllegalComponentStateException ("component not showing");

    // We know peer != null here.
    return peer.getLocationOnScreen ();
  }

  /**
   * Returns the location of this component's top left corner relative to
   * its parent component.
   *
   * @return The location of this component.
   *
   * @deprecated This method is deprecated in favor of 
   * <code>getLocation()</code>.
   */
  public Point location()
  {
    return getLocation();
  }

  /**
   * Moves this component to the specified location.  The coordinates are
   * the new upper left corner of this component.
   *
   * @param x The new X coordinate of this component.
   * @param y The new Y coordinate of this component.
   */
  public void setLocation (int x, int y)
  {
    if ((this.x == x) && (this.y == y))
      return;

    invalidate();

    this.x = x;
    this.y = y;
    if (peer != null)
      peer.setBounds(x, y, width, height);
  }

  /**
   * Moves this component to the specified location.  The coordinates are
   * the new upper left corner of this component.
   *
   * @param x The new X coordinate of this component.
   * @param y The new Y coordinate of this component.
   *
   * @deprecated Deprecated in favor for <code>setLocation</code>.
   */
  public void move(int x, int y)
  {
    setLocation(x,y);
  }

  /**
   * Moves this component to the specified location.  The coordinates are
   * the new upper left corner of this component.
   *
   * @param p New coordinates for this component.
   */
  public void setLocation(Point p)
  {
    setLocation(p.x, p.y);
  }

  /**
   * Returns the size of this object.
   *
   * @return The size of this object.
   */
  public Dimension getSize()
  {
    return new Dimension(width, height);
  }

  /**
   * Returns the size of this object.
   *
   * @return The size of this object.
   *
   * @deprecated This method is deprecated in favor of <code>getSize</code>.
   */
  public Dimension size()
  {
    return getSize();
  }

  /**
   * Sets the size of this component to the specified width and height.
   * 
   * @param width The new width of this component.
   * @param height The new height of this component.
   */
  public void setSize(int width, int height)
  {
    if ((this.width == width) && (this.height == height))
      return;

    invalidate();

    this.width = width;
    this.height = height;
    if (peer != null)
      peer.setBounds(x, y, width, height);
  }

  /**
   * Sets the size of this component to the specified value.
   * 
   * @param width The new width of the component.
   * @param height The new height of the component.
   *
   * @deprecated This method is deprecated in favor of <code>setSize</code>.
   */
  public void resize(int width, int height)
  {
    setSize(width, height);
  }

  /**
   * Sets the size of this component to the specified value.
   * 
   * @param dim The new size of this component.
   */
  public void setSize(Dimension d)
  {
    setSize(d.width, d.height);
  }

  /**
   * Sets the size of this component to the specified value.
   * 
   * @param dim The new size of this component.
   *
   * @deprecated This method is deprecated in favor of <code>setSize</code>.
   */
  public void resize(Dimension d)
  {
    setSize(d.width, d.height);
  }

  /**
   * Returns a bounding rectangle for this component.  Note that the
   * returned rectange is relative to this component's parent, not to
   * the screen.
   *
   * @return The bounding rectangle for this component.
   */
  public Rectangle getBounds()
  {
    return new Rectangle (x, y, width, height);
  }

  /**
   * Returns a bounding rectangle for this component.  Note that the
   * returned rectange is relative to this component's parent, not to
   * the screen.
   *
   * @return The bounding rectangle for this component.
   *
   * @deprecated Deprecated in favor of <code>getBounds()</code>.
   */
  public Rectangle bounds()
  {
    return getBounds();
  }

  /**
   * Sets the bounding rectangle for this component to the specified
   * values.  Note that these coordinates are relative to the parent,
   * not to the screen.
   *
   * @param x The X coordinate of the upper left corner of the rectangle.
   * @param y The Y coordinate of the upper left corner of the rectangle.
   * @param width The width of the rectangle.
   * @param height The height of the rectangle.
   */
  public void setBounds(int x, int y, int w, int h)
  {
    if (this.x == x
	&& this.y == y
	&& this.width == w
	&& this.height == h)
      return;

    invalidate();

    this.x = x;
    this.y = y;
    this.width = w;
    this.height = h;

    if (peer != null)
      peer.setBounds(x, y, w, h);
  }

  /**
   * Sets the bounding rectangle for this component to the specified
   * values.  Note that these coordinates are relative to the parent,
   * not to the screen.
   *
   * @param x The X coordinate of the upper left corner of the rectangle.
   * @param y The Y coordinate of the upper left corner of the rectangle.
   * @param width The width of the rectangle.
   * @param height The height of the rectangle.
   *
   * @deprecated This method is deprecated in favor of
   * <code>setBounds(int, int, int, int)</code>.
   */
  public void reshape(int x, int y, int width, int height)
  {
    setBounds(x, y, width, height);
  }

  /**
   * Sets the bounding rectangle for this component to the specified
   * rectangle.  Note that these coordinates are relative to the parent,
   * not to the screen.
   *
   * @param bounding_rectangle The new bounding rectangle.
   */
  public void setBounds(Rectangle r)
  { 
    setBounds(r.x, r.y, r.width, r.height);
  }
  
  /** @since 1.2 */
  public int getX()
  {
    return x;
  }
  
  /** @since 1.2 */
  public int getY()
  {
    return y;
  }
  
  /** @since 1.2 */
  public int getWidth()
  {
    return width;
  }
  
  /** @since 1.2 */
  public int getHeight()
  {
    return height;
  }
  
  public Rectangle getBounds(Rectangle r)
  {
    r.x = this.x;
    r.y = this.y;
    r.width = this.width;
    r.height = this.height;
    return r;
  }
  
  public Dimension getSize(Dimension d)
  {
    d.width = this.width;
    d.height = this.height;
    return d;
  }
  
  public Point getLocation(Point p)
  {
    p.x = x;
    p.y = y;
    return p;
  }
  
  /** @since 1.2 */
  public boolean isOpaque()
  {
    return !isLightweight();
  }
  
  /** 
   * Return whether the component is lightweight.
   *
   * @return true if component has a peer and and the peer is lightweight.
   *
   * @since 1.2
   */  
  public boolean isLightweight()
  {
    return (peer != null) && (peer instanceof LightweightPeer);
  }

  /**
   * Returns the component's preferred size.
   *
   * @return The component's preferred size.
   */
  public Dimension getPreferredSize()
  {
    if (peer == null)
      return new Dimension(width, height);
    else
      return peer.getPreferredSize();
  }

  /**
   * Returns the component's preferred size.
   *
   * @return The component's preferred size.
   *
   * @deprecated Deprecated in favor of <code>getPreferredSize()</code>.
   */
  public Dimension preferredSize()
  {
    return getPreferredSize();
  }

  /**
   * Returns the component's minimum size.
   *
   * @return The component's minimum size.
   */
  public Dimension getMinimumSize()
  {
    if (peer == null)
      return new Dimension(width, height);
    else
      return peer.getMinimumSize();
  }

  /**
   * Returns the component's minimum size.
   *
   * @return The component's minimum size.
   *
   * @deprecated Deprecated in favor of <code>getMinimumSize()</code>
   */
  public Dimension minimumSize()
  {
    return getMinimumSize();
  }

  /**
   * Returns the component's maximum size.
   *
   * @return The component's maximum size.
   */
  public Dimension getMaximumSize()
  {
    return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
  }

  /**
   * Returns the preferred horizontal alignment of this component.  The
   * value returned will be one of the constants defined in this class.
   *
   * @return The preferred horizontal alignment of this component.
   */
  public float getAlignmentX()
  {
    return CENTER_ALIGNMENT;
  }

  /**
   * Returns the preferred vertical alignment of this component.  The
   * value returned will be one of the constants defined in this class.
   *
   * @return The preferred vertical alignment of this component.
   */
  public float getAlignmentY()
  {
    return CENTER_ALIGNMENT;
  }

  /**
   * Calls the layout manager to re-layout the component.  This is called
   * during validation of a container in most cases.
   */
  public void doLayout()
  {
    // nothing to do unless we're a container
  }

  /**
   * Calls the layout manager to re-layout the component.  This is called
   * during validation of a container in most cases.
   *
   * @deprecated This method is deprecated in favor of <code>doLayout()</code>.
   */
  public void layout()
  {
    doLayout();
  }

  /**
   * Called to ensure that the layout for this component is valid.
   */
  public void validate()
  {
    valid = true;
  }

  /**
   * Invalidates this component and all of its parent components.  This will
   * cause them to have their layout redone.
   */
  public void invalidate()
  {
    valid = false;

    if ((parent != null) && parent.valid)
      parent.invalidate ();
  }

  /**
   * Returns a graphics object for this component.  Returns <code>null</code>
   * if this component is not currently displayed on the screen.
   *
   * @return A graphics object for this component.
   */
  public Graphics getGraphics()
  {
    if (peer != null)
      {
	Graphics gfx = peer.getGraphics();
	if (gfx != null)
	  return gfx;
      
	// create graphics for lightweight:
	Container parent = getParent();
	if (parent != null)
	  {
	    gfx = parent.getGraphics();
	    Rectangle bounds = getBounds();
	    gfx.setClip(bounds);
	    gfx.translate(bounds.x, bounds.y);
	    return gfx;
	  }
      }
    return null;
  }

  /**
   * Returns the font metrics for the specified font in this component.
   *
   * @param font The font to retrieve metrics for.
   *
   * @return The font metrics for the specified font.
   */
  public FontMetrics getFontMetrics(Font font)
  {
    if (peer == null)
      return getToolkit().getFontMetrics(font);
    return peer.getFontMetrics (font);
  }

  /**
   * Sets the cursor for this component to the specified cursor.
   *
   * @param cursor The new cursor for this component.
   */
  public void setCursor(Cursor cursor)
  {
    this.cursor = cursor;
    if (peer != null)
      peer.setCursor (cursor);
  }

  /**
   * Returns the cursor for this component.
   *
   * @return The cursor for this component.
   */
  public Cursor getCursor()
  {
    return this.cursor;
  }

  /**
   * Paints this component on the screen.  The clipping region in the
   * graphics context will indicate the region that requires painting.
   *
   * @param graphics The graphics context for this paint job.
   */
  public void paint(Graphics g)
  {
  }

  /**
   * Updates this component.  This method fills the component
   * with the background color, then sets the foreground color of the
   * specified graphics context to the foreground color of this component
   * and calls the <code>paint()</code> method.
   * // FIXME: What are the coords relative to?
   *
   * @param graphics The graphics context for this update.
   */
  public void update(Graphics g)
  {
    paint(g);
  }

  /**
   * Paints this entire component, including any sub-components.
   *
   * @param graphics The graphics context for this paint job.
   */
  public void paintAll(Graphics g)
  {    
    if (!visible)
      return;
	
    if (peer != null)
      peer.paint(g);
    paint(g);
  }

  /**
   * Repaint this entire component.  The <code>update()</code> method
   * on this component will be called as soon as possible.
   * // FIXME: What are the coords relative to?
   */
  public void repaint()
  {
    repaint(0, 0, 0, getWidth(), getHeight());
  }

  /**
   * Repaint this entire component.  The <code>update()</code> method
   * on this component will be called in approximate the specified number
   * of milliseconds.
   * // FIXME: What are the coords relative to?
   *
   * @param tm The number of milliseconds before this component should
   * be repainted.
   */
  public void repaint(long tm)
  {
    repaint(tm, 0, 0, getWidth(), getHeight());
  }

  /**
   * Repaints the specified rectangular region within this component.
   * This <code>update</code> method on this component will be called as
   * soon as possible.
   * // FIXME: What are the coords relative to?
   *
   * @param x The X coordinate of the upper left of the region to repaint
   * @param y The Y coordinate of the upper left of the region to repaint
   * @param width The width of the region to repaint.
   * @param height The height of the region to repaint.
   */
  public void repaint(int x, int y, int width, int height)
  {
    repaint(0, x, y, width, height);
  }

  /**
   * Repaints the specified rectangular region within this component.
   * This <code>update</code> method on this component will be called in
   * approximately the specified number of milliseconds.
   * // FIXME: What are the coords relative to?
   *
   * @param tm The number of milliseconds before this component should
   * be repainted.
   * @param x The X coordinate of the upper left of the region to repaint
   * @param y The Y coordinate of the upper left of the region to repaint
   * @param width The width of the region to repaint.
   * @param height The height of the region to repaint.
   */
  public void repaint(long tm, int x, int y, int width, int height)
  {    
    // Handle lightweight repainting by forwarding to native parent
    if (isLightweight() && (parent != null))
      {
	if (parent != null)
	  parent.repaint(tm, x+getX(), y+getY(), width, height);
	return;
      }

    if (peer != null)
      peer.repaint(tm, x, y, width, height);
  }

  /**
   * Prints this component.  This method is
   * provided so that printing can be done in a different manner from
   * painting.  However, the implementation in this class simply calls
   * the <code>paint()</code> method.
   *
   * @param graphics The graphics context of the print device.
   */
  public void print(Graphics g)
  {
    paint(g);
  }

  /**
   * Prints this component, including all sub-components.  This method is
   * provided so that printing can be done in a different manner from
   * painting.  However, the implementation in this class simply calls
   * the <code>paintAll()</code> method.
   *
   * @param graphics The graphics context of the print device.
   */
  public void printAll(Graphics g)
  {
    paintAll(g);
  }

  /**
   * Called when an image has changed so that this component is
   * repainted.
   *
   * @param image The image that has been updated.
   * @param flags Flags as specified in <code>ImageObserver</code>.
   * @param x The X coordinate 
   * @param y The Y coordinate
   * @param width The width
   * @param height The height
   *
   * @return <code>true</code> if the image has been fully loaded,
   * <code>false</code> otherwise.
   */
  public boolean imageUpdate (Image img, int infoflags, int x, int y,
			      int w, int h)
  {
    // FIXME
    return false;
  }

  /**
   * Creates an image from the specified producer.
   *
   * @param producer The image procedure to create the image from.
   *
   * @return The resulting image.
   */
  public Image createImage(ImageProducer producer)
  {
    return peer.createImage(producer);
  }

  /**
   * Creates an image with the specified width and height for use in
   * double buffering.
   *
   * @param width The width of the image.
   * @param height The height of the image.
   *
   * @return The requested image.
   */
  public Image createImage(int width, int height)
  {
    return getGraphicsConfiguration().createCompatibleImage(width, height);
  }

  /**
   * Prepares the specified image for rendering on this component.
   *
   * @param image The image to prepare for rendering.
   * @param observer The image observer to notify of the status of the
   * image preparation.
   *
   * @return <code>true</code> if the image is already fully prepared
   * for rendering, <code>false</code> otherwise.
   */
  public boolean prepareImage(Image image, ImageObserver observer)
  {
    return prepareImage(image, image.getWidth(observer), 
			image.getHeight(observer), observer);
  }

  /**
   * Prepares the specified image for rendering on this component at the
   * specified scaled width and height
   *
   * @param image The image to prepare for rendering.
   * @param width The scaled width of the image.
   * @param height The scaled height of the image.
   * @param observer The image observer to notify of the status of the
   * image preparation.
   *
   * @return <code>true</code> if the image is already fully prepared
   * for rendering, <code>false</code> otherwise.
   */
  public boolean prepareImage(Image image, int width, int height,
			      ImageObserver observer)
  {
    return peer.prepareImage(image, width, height, observer);
  }

  /**
   * Returns the status of the loading of the specified image. The value
   * returned will be those flags defined in <code>ImageObserver</code>.
   *
   * @param image The image to check on.
   * @param observer The observer to be notified as the image loading
   * progresses.
   *
   * @return The image observer flags indicating the status of the load.
   */
  public int checkImage(Image image, ImageObserver observer)
  {
    return checkImage(image, image.getWidth(observer), 
		      image.getHeight(observer), observer);
  }

  /**
   * Returns the status of the loading of the specified image. The value
   * returned will be those flags defined in <code>ImageObserver</code>.
   *
   * @param image The image to check on.
   * @param width The scaled image width.
   * @param height The scaled image height.
   * @param observer The observer to be notified as the image loading
   * progresses.
   *
   * @return The image observer flags indicating the status of the load.
   */
  public int checkImage (Image image, int width, int height,
			 ImageObserver observer)
  {
    if (peer != null)
      return peer.checkImage (image, width, height, observer);
    return getToolkit ().checkImage (image, width, height, observer);
  }

  /**
   * Tests whether or not the specified point is contained within this
   * component.  Coordinates are relative to this component.
   *
   * @param x The X coordinate of the point to test.
   * @param y The Y coordinate of the point to test.
   *
   * @return <code>true</code> if the point is within this component,
   * <code>false</code> otherwise.
   */
  public boolean contains (int x, int y)
  {
    return (x >= 0) && (y >= 0) && (x < width) && (y < height);
  }

  /**
   * Tests whether or not the specified point is contained within this
   * component.  Coordinates are relative to this component.
   *
   * @param x The X coordinate of the point to test.
   * @param y The Y coordinate of the point to test.
   *
   * @return <code>true</code> if the point is within this component,
   * <code>false</code> otherwise.
   *
   * @deprecated Deprecated in favor of <code>contains(int, int)</code>.
   */
  public boolean inside(int x, int y)
  {
    return contains(x,y);
  }

  /**
   * Tests whether or not the specified point is contained within this
   * component.  Coordinates are relative to this component.
   *
   * @param point The point to test.
   *
   * @return <code>true</code> if the point is within this component,
   * <code>false</code> otherwise.
   */
  public boolean contains(Point p)
  {
    return contains(p.x, p.y);
  }

  /**
   * Returns the component occupying the position (x,y).  This will either
   * be this component, an immediate child component, or <code>null</code>
   * if neither of the first two occupies the specified location.
   *
   * @param x The X coordinate to search for components at.
   * @param y The Y coordinate to search for components at.
   *
   * @return The component at the specified location, for <code>null</code>
   * if there is none.
   */
  public Component getComponentAt(int x, int y)
  {
    if (contains(x,y))
      return this;
    return null;
  }

  /**
   * Returns the component occupying the position (x,y).  This will either
   * be this component, an immediate child component, or <code>null</code>
   * if neither of the first two occupies the specified location.
   *
   * @param x The X coordinate to search for components at.
   * @param y The Y coordinate to search for components at.
   *
   * @return The component at the specified location, for <code>null</code>
   * if there is none.
   *
   * @deprecated The method is deprecated in favor of 
   * <code>getComponentAt()</code>.
   */
  public Component locate(int x, int y)
  {
    return getComponentAt(x, y);
  }

  /**
   * Returns the component occupying the specified point  This will either
   * be this component, an immediate child component, or <code>null</code>
   * if neither of the first two occupies the specified location.
   *
   * @param point The point to search for components at.
   *
   * @return The component at the specified location, for <code>null</code>
   * if there is none.
   */
  public Component getComponentAt(Point p)
  {
    return getComponentAt(p.x, p.y);
  }

  /**
   * AWT 1.0 event dispatcher.
   *
   * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
   */
  public void deliverEvent(Event e)
  {
  }

  /** Forward AWT events to processEvent() if:
    *     - Events have been enabled for this type of event via enableEvents(),
    *   OR:
    *	 - There is at least one registered listener for this type of event
    * 
    * @param event The event to dispatch
    *
    * @specnote This method is final, but we need to be able to 
    *           override it in order to handle other event types in our 
    *	        subclasses. The solution is to define a second, non-final
    *           method - dispatchEventImpl() - to actually do the work. 
    *           Investigations with Thread.dumpStack() on the dispatch thread 
    *           in JDK 1.3 show Sun's implementation is doing the same 
    *           thing.
    */
  public final void dispatchEvent(AWTEvent e)
  {
    dispatchEventImpl(e);

    /* Give the peer a chance to handle the event. */
    if (peer != null)
      peer.handleEvent(e);
  }

  void dispatchEventImpl(AWTEvent e)
  {
    // Make use of event id's in order to avoid multiple instanceof tests.
    if (e.id <= ComponentEvent.COMPONENT_LAST 
        && e.id >= ComponentEvent.COMPONENT_FIRST
        && (componentListener != null 
	    || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0))
      processEvent(e);
    else if (e.id <= KeyEvent.KEY_LAST
             && e.id >= KeyEvent.KEY_FIRST
	     && (keyListener != null
		 || (eventMask & AWTEvent.KEY_EVENT_MASK) != 0))
      processEvent(e);
    else if (e.id <= MouseEvent.MOUSE_LAST
             && e.id >= MouseEvent.MOUSE_FIRST
	     && (mouseListener != null
		 || mouseMotionListener != null
		 || (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0))
      processEvent(e);
    else if (e.id <= FocusEvent.FOCUS_LAST
             && e.id >= FocusEvent.FOCUS_FIRST
	     && (focusListener != null
		 || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0))
      processEvent(e);
    else if (e.id <= InputMethodEvent.INPUT_METHOD_LAST
             && e.id >= InputMethodEvent.INPUT_METHOD_FIRST
	     && (inputMethodListener != null
		 || (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0))
      processEvent(e);
    else if (e.id <= HierarchyEvent.HIERARCHY_LAST
             && e.id >= HierarchyEvent.HIERARCHY_FIRST
	     && (hierarchyListener != null
		 || hierarchyBoundsListener != null
		 || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0))
      processEvent(e);
    else if (e.id <= PaintEvent.PAINT_LAST
	     && e.id >= PaintEvent.PAINT_FIRST
	     && (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0)      
      processEvent(e);
  }
  
  /**
   * AWT 1.0 event dispatcher.
   *
   * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
   */
  public boolean postEvent(Event e)
  {
    return false;
  }

  /**
   * Adds the specified listener to this component.
   *
   * @param listener The new listener to add.
   */
  public synchronized void addComponentListener(ComponentListener l)
  {
    componentListener = AWTEventMulticaster.add(componentListener, l);
    if (componentListener != null)
      enableEvents(AWTEvent.COMPONENT_EVENT_MASK);
  }

  /**
   * Removes the specified listener from the component.
   *
   * @param listener The listener to remove.
   */
  public synchronized void removeComponentListener(ComponentListener l)
  {
    componentListener = AWTEventMulticaster.remove(componentListener, l);
  }

  /**
   * Adds the specified listener to this component.
   *
   * @param listener The new listener to add.
   */
  public synchronized void addFocusListener(FocusListener l)
  {
    focusListener = AWTEventMulticaster.add(focusListener, l);
    if (focusListener != null)
      enableEvents(AWTEvent.FOCUS_EVENT_MASK);    
  }

  /**
   * Removes the specified listener from the component.
   *
   * @param listener The listener to remove.
   */
  public synchronized void removeFocusListener(FocusListener l)
  {
    focusListener = AWTEventMulticaster.remove(focusListener, l);
  }
  
  /** @since 1.3 */
  public synchronized void addHierarchyListener(HierarchyListener l)
  {
    hierarchyListener = AWTEventMulticaster.add(hierarchyListener, l);
    if (hierarchyListener != null)
      enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);    
  }
  
  /** @since 1.3 */
  public synchronized void removeHierarchyListener(HierarchyListener l)
  {
    hierarchyListener = AWTEventMulticaster.remove(hierarchyListener, l);
  }

  /** @since 1.3 */
  public synchronized void addHierarchyBoundsListener(HierarchyBoundsListener l)
  {
    hierarchyBoundsListener = 
      AWTEventMulticaster.add(hierarchyBoundsListener, l);
    if (hierarchyBoundsListener != null)
      enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);    
  }

  /** @since 1.3 */
  public synchronized void 
    removeHierarchyBoundsListener(HierarchyBoundsListener l)
  {
    hierarchyBoundsListener = 
      AWTEventMulticaster.remove(hierarchyBoundsListener, l);
  }

  /**
   * Adds the specified listener to this component.
   *
   * @param listener The new listener to add.
   */
  public synchronized void addKeyListener(KeyListener l)
  {
    keyListener = AWTEventMulticaster.add(keyListener, l);
    if (keyListener != null)
      enableEvents(AWTEvent.KEY_EVENT_MASK);    
  }

  /**
   * Removes the specified listener from the component.
   *
   * @param listener The listener to remove.
   */
  public synchronized void removeKeyListener(KeyListener l)
  {
    keyListener = AWTEventMulticaster.remove(keyListener, l);
  }

  /**
   * Adds the specified listener to this component.
   *
   * @param listener The new listener to add.
   */
  public synchronized void addMouseListener(MouseListener l)
  {
    mouseListener = AWTEventMulticaster.add(mouseListener, l);
    if (mouseListener != null)
      enableEvents(AWTEvent.MOUSE_EVENT_MASK);    
  }

  /**
   * Removes the specified listener from the component.
   *
   * @param listener The listener to remove.
   */
  public synchronized void removeMouseListener(MouseListener l)
  {
    mouseListener = AWTEventMulticaster.remove(mouseListener, l);    
  }

  /**
   * Adds the specified listener to this component.
   *
   * @param listener The new listener to add.
   */
  public synchronized void addMouseMotionListener(MouseMotionListener l)
  {
    mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, l);
    if (mouseMotionListener != null)
      enableEvents(AWTEvent.MOUSE_EVENT_MASK);    
  }

  /**
   * Removes the specified listener from the component.
   *
   * @param listener The listener to remove.
   */
  public synchronized void removeMouseMotionListener(MouseMotionListener l)
  {
    mouseMotionListener = AWTEventMulticaster.remove(mouseMotionListener, l);
  }

  /** @since 1.2 */
  public synchronized void addInputMethodListener(InputMethodListener l)
  {
    inputMethodListener = AWTEventMulticaster.add(inputMethodListener, l);
    if (inputMethodListener != null)
      enableEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);    
  }

  /** @since 1.2 */
  public synchronized void removeInputMethodListener(InputMethodListener l)
  {
    inputMethodListener = AWTEventMulticaster.remove(inputMethodListener, l);
  }

  /** Returns all registered EventListers of the given listenerType. 
    * listenerType must be a subclass of EventListener, or a 
    * ClassClassException is thrown.
    * @since 1.3 
    */
  public EventListener[] getListeners(Class listenerType)
  {
    if (listenerType == ComponentListener.class)
      return getListenersImpl(listenerType, componentListener);
    else if (listenerType == FocusListener.class)
      return getListenersImpl(listenerType, focusListener);
    else if (listenerType == KeyListener.class)
      return getListenersImpl(listenerType, keyListener);
    else if (listenerType == MouseListener.class)
      return getListenersImpl(listenerType, mouseListener);
    else if (listenerType == MouseMotionListener.class)
      return getListenersImpl(listenerType, mouseMotionListener);
    else if (listenerType == InputMethodListener.class)
      return getListenersImpl(listenerType, inputMethodListener);
    else if (listenerType == HierarchyListener.class)
      return getListenersImpl(listenerType, hierarchyListener);
    else if (listenerType == HierarchyBoundsListener.class)
      return getListenersImpl(listenerType, hierarchyBoundsListener);
    else
      return getListenersImpl(listenerType, null);
  }
  
  static EventListener[] getListenersImpl(Class listenerType, EventListener el)
  {
    if (! EventListener.class.isAssignableFrom(listenerType))
      throw new ClassCastException();
    
    Vector v = new Vector();
    if (el != null)
      getListenerList (el, v);    
    EventListener[] el_a = (EventListener[]) Array.newInstance(listenerType, 
							       v.size());
    v.copyInto(el_a);
    return el_a;
  }

  static void getListenerList(EventListener el, Vector v)
  {
    if (el instanceof AWTEventMulticaster)
      {
        AWTEventMulticaster mc = (AWTEventMulticaster) el;
        getListenerList(mc.a, v);
	getListenerList(mc.b, v);
      }
    else
      v.addElement(el);      
  }

  // The input method framework is currently unimplemented.  
  // /** @since 1.2 */
  //
  //public InputMethodRequests getInputMethodRequests()
  //
  // /** @since 1.2 */
  //
  // public InputContext getInputContext()

  /**
   * Enables the specified events.  The events to enable are specified
   * by OR-ing together the desired masks from <code>AWTEvent</code>.
   * <p>
   * Events are enabled by default when a listener is attached to the
   * component for that event type.  This method can be used by subclasses
   * to ensure the delivery of a specified event regardless of whether
   * or not a listener is attached.
   *
   * @param enable_events The desired events to enable.
   */
  protected final void enableEvents(long eventsToEnable)
  {
    eventMask |= eventsToEnable;
    // TODO: Unlike Sun's implementation, I think we should try and 
    // enable/disable events at the peer (gtk/X) level. This will avoid 
    // clogging the event pipeline with useless mousemove events that 
    // we arn't interested in, etc. This will involve extending the peer 
    // interface, but thats okay because the peer interfaces have been
    // deprecated for a long time, and no longer feature in the 
    // API specification at all.

    if (isLightweight() && (parent != null))
      parent.enableEvents(eventsToEnable);
    else if (peer != null)
      peer.setEventMask (eventMask);
  }

  /**
   * Disables the specified events.  The events to disable are specified
   * by OR-ing together the desired masks from <code>AWTEvent</code>.
   *
   * @param disable_events The desired events to disable.
   */
  protected final void disableEvents(long eventsToDisable)
  {
    eventMask &= ~eventsToDisable;
    // forward new event mask to peer?
  }

  /** coalesceEvents is called by the EventQueue if two events with the same 
    * event id are queued. Returns a new combined event, or null if no 
    * combining is done. 
    */
  protected AWTEvent coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)
  {
    switch (existingEvent.id)
      {
      case MouseEvent.MOUSE_MOVED:
      case MouseEvent.MOUSE_DRAGGED:
	// Just drop the old (intermediate) event and return the new one.
	return newEvent;
      case PaintEvent.PAINT:
      case PaintEvent.UPDATE:
	return coalescePaintEvents((PaintEvent) existingEvent,
				   (PaintEvent) newEvent);
      }
    return null;
  }
  
  /**
   * Coalesce paint events. Current heuristic is: Merge if the union of
   * areas is less than twice that of the sum of the areas. The X server
   * tend to create a lot of paint events that are adjacent but not
   * overlapping.
   *
   * <pre>
   * +------+
   * |      +-----+  ...will be merged
   * |      |     |
   * |      |     |
   * +------+     |
   *        +-----+
   * 
   * +---------------+--+
   * |               |  |  ...will not be merged
   * +---------------+  |
   *                 |  |
   *                 |  |
   *                 |  |
   *                 |  |
   *                 |  |
   *                 +--+
   * </pre>
   */
  private PaintEvent coalescePaintEvents(PaintEvent queuedEvent,
					 PaintEvent newEvent)
  {
    Rectangle r1 = queuedEvent.getUpdateRect();
    Rectangle r2 = newEvent.getUpdateRect();
    Rectangle union = r1.union(r2);
    
    int r1a = r1.width * r1.height;
    int r2a = r2.width * r2.height;
    int ua  = union.width * union.height;
    
    if (ua > (r1a+r2a)*2)
      return null;
    /* The 2 factor should maybe be reconsidered. Perhaps 3/2
       would be better? */

    newEvent.setUpdateRect(union);
    return newEvent;
  }

  /**
   * Processes the specified event.  In this class, this method simply
   * calls one of the more specific event handlers.
   * 
   * @param event The event to process.
   */
  protected void processEvent(AWTEvent e)
  {

    /* Note: the order of these if statements are
       important. Subclasses must be checked first. Eg. MouseEvent
       must be checked before ComponentEvent, since a MouseEvent
       object is also an instance of a ComponentEvent. */

    if (e instanceof FocusEvent)
      processFocusEvent((FocusEvent) e);
    else if (e instanceof PaintEvent)
      processPaintEvent((PaintEvent) e);
    else if (e instanceof MouseEvent)
      {
        if (e.id == MouseEvent.MOUSE_MOVED 
	    || e.id == MouseEvent.MOUSE_DRAGGED)
	  processMouseMotionEvent((MouseEvent) e);
	else
	  processMouseEvent((MouseEvent) e);
      }
    else if (e instanceof ComponentEvent)
      processComponentEvent((ComponentEvent) e);
    else if (e instanceof KeyEvent)
      processKeyEvent((KeyEvent) e);
    else if (e instanceof InputMethodEvent)
      processInputMethodEvent((InputMethodEvent) e);
    else if (e instanceof HierarchyEvent)
      {
        if (e.id == HierarchyEvent.HIERARCHY_CHANGED)
	  processHierarchyEvent((HierarchyEvent) e);
	else
	  processHierarchyBoundsEvent((HierarchyEvent) e);
      }
  }

  /**
   * Called when a component event is dispatched and component events are
   * enabled.  This method passes the event along to any listeners
   * that are attached.
   *
   * @param event The <code>ComponentEvent</code> to process.
   */
  protected void processComponentEvent(ComponentEvent e)
  {
    if (componentListener == null)
      return;
    switch (e.id)
      {
        case ComponentEvent.COMPONENT_HIDDEN:
	  componentListener.componentHidden(e);
	break;
		
        case ComponentEvent.COMPONENT_MOVED:
	  componentListener.componentMoved(e);
	break;
	
	case ComponentEvent.COMPONENT_RESIZED:
	  componentListener.componentResized(e);
	break;
	
	case ComponentEvent.COMPONENT_SHOWN:
	  componentListener.componentShown(e);
	break;
      }
  }

  /**
   * Called when a focus event is dispatched and component events are
   * enabled.  This method passes the event along to any listeners
   * that are attached.
   *
   * @param event The <code>FocusEvent</code> to process.
   */
  protected void processFocusEvent(FocusEvent e)
  {
    if (focusListener == null)
      return;
    switch (e.id)
      {
        case FocusEvent.FOCUS_GAINED:
	  focusListener.focusGained(e);
	break;
        case FocusEvent.FOCUS_LOST:
	  focusListener.focusLost(e);
	break;
      }    
  }

  /**
   * Called when a key event is dispatched and component events are
   * enabled.  This method passes the event along to any listeners
   * that are attached.
   *
   * @param event The <code>KeyEvent</code> to process.
   */
  protected void processKeyEvent(KeyEvent e)
  {
    if (keyListener == null)
      return;
    switch (e.id)
      {
	case KeyEvent.KEY_PRESSED:
	  keyListener.keyPressed(e);
	break;
	case KeyEvent.KEY_RELEASED:
	  keyListener.keyReleased(e);
	break;
	case KeyEvent.KEY_TYPED:
	  keyListener.keyTyped(e);
	break;
      }
  }

  /**
   * Called when a regular mouse event is dispatched and component events are
   * enabled.  This method passes the event along to any listeners
   * that are attached.
   *
   * @param event The <code>MouseEvent</code> to process.
   */
  protected void processMouseEvent(MouseEvent e)
  {
    if (mouseListener == null)
      return;
    switch (e.id)
      {
	case MouseEvent.MOUSE_CLICKED:
	  mouseListener.mouseClicked(e);
	break;
        case MouseEvent.MOUSE_ENTERED:
	  mouseListener.mouseEntered(e);
	break;
	case MouseEvent.MOUSE_EXITED:
	  mouseListener.mouseExited(e);
	break;
	case MouseEvent.MOUSE_PRESSED:
	  mouseListener.mousePressed(e);
	break;
	case MouseEvent.MOUSE_RELEASED:
	  mouseListener.mouseReleased(e);
	break;
      }
  }

  /**
   * Called when a mouse motion event is dispatched and component events are
   * enabled.  This method passes the event along to any listeners
   * that are attached.
   *
   * @param event The <code>MouseMotionEvent</code> to process.
   */
  protected void processMouseMotionEvent(MouseEvent e)
  {
    if (mouseMotionListener == null)
      return;
    switch (e.id)
      {
	case MouseEvent.MOUSE_DRAGGED:
	  mouseMotionListener.mouseDragged(e);
	break;
        case MouseEvent.MOUSE_MOVED:
	  mouseMotionListener.mouseMoved(e);
	break;
      }	
  }

  /** @since 1.2 */
  protected void processInputMethodEvent(InputMethodEvent e)
  {
    if (inputMethodListener == null)
      return;
    switch (e.id)
      {
	case InputMethodEvent.CARET_POSITION_CHANGED:
          inputMethodListener.caretPositionChanged(e);
	break;
	case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
          inputMethodListener.inputMethodTextChanged(e);
	break;
      }	
  }
  
  /** @since 1.3 */
  protected void processHierarchyEvent(HierarchyEvent e)
  {
    if (hierarchyListener == null)
      return;
    if (e.id == HierarchyEvent.HIERARCHY_CHANGED)
      hierarchyListener.hierarchyChanged(e);
  }
  
  /** @since 1.3 */
  protected void processHierarchyBoundsEvent(HierarchyEvent e)
  {
    if (hierarchyBoundsListener == null)
      return;
    switch (e.id)
      {
        case HierarchyEvent.ANCESTOR_MOVED:
	  hierarchyBoundsListener.ancestorMoved(e);
	break;
	case HierarchyEvent.ANCESTOR_RESIZED:
	  hierarchyBoundsListener.ancestorResized(e);
	break;
      }
  }

  private void processPaintEvent(PaintEvent event)
  {
    // Can't do graphics without peer
    if (peer == null)
      return;

    Graphics gfx = getGraphics();
    Shape clip = event.getUpdateRect();
    gfx.setClip(clip);

    switch (event.id)
      {
      case PaintEvent.PAINT:
	paint(gfx);
	break;
      case PaintEvent.UPDATE:
	update(gfx);
	break;
      default:
	throw new IllegalArgumentException("unknown paint event");
      }
  }

  /**
   * AWT 1.0 event processor.
   *
   * @deprecated Deprecated in favor of <code>processEvent</code>.
   */
  public boolean handleEvent(Event evt)
  {
    return false;
  }

  /**
   * AWT 1.0 mouse event.
   *
   * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
   */
  public boolean mouseDown(Event evt, int x, int y)
  {
    return false;
  }
  
  /**
   * AWT 1.0 mouse event.
   *
   * @deprecated Deprecated in favor of <code>processMouseMotionEvent()</code>.
   */
  public boolean mouseDrag(Event evt, int x, int y)
  {
    return false;
  }

  /**
   * AWT 1.0 mouse event.
   *
   * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
   */
  public boolean mouseUp(Event evt, int x, int y)
  {
    return false;
  }

  /**
   * AWT 1.0 mouse event.
   *
   * @deprecated Deprecated in favor of <code>processMouseMotionEvent()</code>.
   */
  public boolean mouseMove(Event evt, int x, int y)
  {
    return false;
  }

  /**
   * AWT 1.0 mouse event.
   *
   * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
   */
  public boolean mouseEnter(Event evt, int x, int y)
  {
    return false;
  }

  /**
   * AWT 1.0 mouse event.
   *
   * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
   */
  public boolean mouseExit(Event evt, int x, int y)
  {
    return false;
  }

  /**
   * AWT 1.0 key press event.
   *
   * @deprecated Deprecated in favor of <code>processKeyEvent</code>.
   */
  public boolean keyDown(Event evt, int key)
  {
    return false;
  }

  /**
   * AWT 1.0 key press event.
   *
   * @deprecated Deprecated in favor of <code>processKeyEvent</code>.
   */
  public boolean keyUp(Event evt, int key)
  {
    return false;
  }

  /**
   * AWT 1.0 action event processor.
   *
   * @deprecated Deprecated in favor of the <code>ActionListener</code>
   * interface.
   */
  public boolean action(Event evt, Object what)
  {
    return false;
  }

  /**
   * Called to inform this component it has been added to a container.
   * A native peer - if any - is created at this time.  This method is
   * called automatically by the AWT system and should not be called by
   * user level code.
   */
  public void addNotify()
  {
    if (peer == null)
      peer = getToolkit().createComponent(this);

    /* Now that all the children has gotten their peers, we should
       have the event mask needed for this component and its
       lightweight subcomponents. */

    peer.setEventMask(eventMask);

    /* We do not invalidate here, but rather leave that job up to
       the peer. For efficiency, the peer can choose not to
       invalidate if it is happy with the current dimensions,
       etc. */
  }

  /**
   * Called to inform this component is has been removed from its
   * container.  Its native peer - if any - is destroyed at this time.
   * This method is called automatically by the AWT system and should
   * not be called by user level code.
   */
  public void removeNotify()
  {    
    if (peer != null)
      peer.dispose();
    peer = null;
  }
  
  /** @deprecated */
  public boolean gotFocus(Event evt, Object what)
  {
    return false;
  }
  
  /** @deprecated */
  public boolean lostFocus(Event evt, Object what)
  {
    return false;
  }

  /**
   * Tests whether or not this component is in the group that can
   * be traversed using the keyboard traversal mechanism (such as the TAB
   * key).
   *
   * @return <code>true</code> if the component is traversed via the TAB
   * key, <code>false</code> otherwise.
   */
  public boolean isFocusTraversable()
  {
    return enabled && visible && (peer == null || peer.isFocusTraversable ());
  }

  /**
   * Requests that this component be given focus.  The <code>gotFocus()</code>
   * method on this event will be called when and if this request was
   * successful.
   */
  public void requestFocus()
  {
    // If there's no peer then this component can't get the focus.  We
    // treat it as a silent rejection of the request.
    if (peer != null)
      peer.requestFocus ();
  }

  // This method is used to implement transferFocus().
  // CHILD is the child making the request.
  // This is overridden by Container; when called for an ordinary
  // component there is no child and so we always return null.
  Component findNextFocusComponent (Component child)
  {
    return null;
  }

  /**
   * Transfers focus to the next component in the focus traversal order.
   */
  public void transferFocus()
  {
    Component next;
    if (parent == null)
      next = findNextFocusComponent (null);
    else
      next = parent.findNextFocusComponent (this);
    if (next != null && next != this)
      next.requestFocus ();
  }

  /**
   * AWT 1.0 focus event processor.
   *
   * @deprecated Deprecated in favor of <code>transferFocus()</code>.
   */
  public void nextFocus()
  {
    transferFocus();
  }

  /** @since 1.2 */
  public boolean hasFocus()
  {
    return hasFocus;
  }

  /**
   * Adds the specified popup menu to this component.
   *
   * @param menu The popup menu to be added.
   */
  public synchronized void add(PopupMenu popup)
  {
    if (popups == null)
      popups = new Vector();
    popups.addElement(popup);    
  }

  /**
   * Removes the specified popup menu from this component.
   *
   * @param menu The popup menu to remove.
   */
  public synchronized void remove(MenuComponent popup)
  {
    popups.removeElement(popup);
  }

  /**
   * Returns a debugging string representing this component.
   *
   * @return A string representing this component.
   */
  protected String paramString()
  {
    StringBuffer param = new StringBuffer();
    String name = getName();
    if (name != null)
      {
	param.append(name);
	param.append(",");
      }
    param.append(width);
    param.append("x");
    param.append(height);
    param.append("+");
    param.append(x);
    param.append("+");
    param.append(y);
    
    if (!isValid())
      param.append(",invalid");
    if (!isVisible())
      param.append(",invisible");
    if (!isEnabled())
      param.append(",disabled");
    if (!isOpaque())
      param.append(",translucent");
    if (isDoubleBuffered())
      param.append(",doublebuffered");
    
    return param.toString();
  }

  /**
   * Returns a string representation of this component.
   *
   * @return A string representation of this component
   */
  public String toString()
  {
    return this.getClass().getName() + "[" + paramString() + "]";
  }

  /**
   * Prints a listing of this component to the standard output.
   */
  public void list ()
  {
    list (System.out, 0);
  }

  /**
   * Prints a listing of this component to the specified print stream.
   *
   * @param stream The <code>PrintStream</code> to print to.
   */
  public void list (PrintStream out)
  {
    list (out, 0);
  }

  /**
   * Prints a listing of this component to the specified print stream,
   * starting at the specified indentation point.
   *
   * @param stream The <code>PrintStream</code> to print to.
   * @param indent The indentation point.
   */
  public void list (PrintStream out, int indent)
  {
    for (int i = 0; i < indent; ++i)
      out.print (' ');
    out.println (toString ());
  }

  /**
   * Prints a listing of this component to the specified print writer.
   *
   * @param writer The <code>PrintWrinter</code> to print to.
   */
  public void list (PrintWriter out)
  {
    list (out, 0);
  }

  /**
   * Prints a listing of this component to the specified print writer,
   * starting at the specified indentation point.
   *
   * @param writer The <code>PrintWriter</code> to print to.
   * @param indent The indentation point.
   */
  public void list (PrintWriter out, int indent)
  {
    for (int i = 0; i < indent; ++i)
      out.print (' ');
    out.println (toString ());
  }

  public void addPropertyChangeListener(PropertyChangeListener listener)
  {
    if (changeSupport == null)
      changeSupport = new PropertyChangeSupport(this);
    changeSupport.addPropertyChangeListener(listener);
  }

  public void removePropertyChangeListener(PropertyChangeListener listener)
  {
    if (changeSupport != null)
      changeSupport.removePropertyChangeListener(listener);         
  }

  public void addPropertyChangeListener(String propertyName,
                                	PropertyChangeListener listener)
  {
    if (changeSupport == null)
      changeSupport = new PropertyChangeSupport(this);
    changeSupport.addPropertyChangeListener(propertyName, listener);  
  }

  public void removePropertyChangeListener(String propertyName,
                                           PropertyChangeListener listener)
  {
    if (changeSupport != null)
      changeSupport.removePropertyChangeListener(propertyName, listener);
  }

  protected void firePropertyChange(String propertyName, Object oldValue, 
                                    Object newValue)
  {
    if (changeSupport != null)
      changeSupport.firePropertyChange(propertyName, oldValue, newValue);    
  }

  public void setComponentOrientation(ComponentOrientation o)
  {
    orientation = o;
  }

  public ComponentOrientation getComponentOrientation()
  {
    return orientation;
  }

  /*
  public AccessibleContext getAccessibleContext()
  {
    return accessibleContext;
  }
  */

/**
  * AWT 1.0 focus event processor.
  *
  * @deprecated Deprecated in favor of <code>processFocusEvent</code>.
  
public boolean
gotFocus(Event event, Object what)
{
  return(true);
}
*/

/**
  * AWT 1.0 focus event processor.
  *
  * @deprecated Deprecated in favor of <code>processFocusEvent</code>.
  
public boolean
lostFocus(Event event, Object what)
{
  return(true);
}
*/

}