1 /* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation
3 This file is part of GNU Classpath.
5 GNU Classpath is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 GNU Classpath is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNU Classpath; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 As a special exception, if you link this library with other files to
21 produce an executable, this library does not by itself cause the
22 resulting executable to be covered by the GNU General Public License.
23 This exception does not however invalidate any other reasons why the
24 executable file might be covered by the GNU General Public License. */
27 import java.awt.event.*;
28 import java.awt.image.*;
29 import java.io.PrintStream;
30 import java.io.PrintWriter;
31 import java.lang.reflect.*;
32 import java.util.EventListener;
33 import java.util.Locale;
34 import java.util.ResourceBundle;
35 import java.util.Vector;
36 import java.awt.peer.ComponentPeer;
37 import java.awt.peer.LightweightPeer;
38 import java.beans.PropertyChangeSupport;
39 import java.beans.PropertyChangeListener;
40 // import javax.accessibility.AccessibleContext;
43 * The root of all evil.
45 * Status: Incomplete. The event dispatch mechanism is implemented. All
46 * other methods defined in the J2SE 1.3 API javadoc exist, but are mostly
47 * incomplete or only stubs; except for methods relating to the Drag and Drop,
48 * Input Method, and Accessibility frameworks: These methods are present but
51 public abstract class Component implements ImageObserver, MenuContainer,
55 * Constant returned by the <code>getAlignmentY</code> method to indicate
56 * that the component wishes to be aligned to the bottom relative to
59 public static final float BOTTOM_ALIGNMENT = (float)1.0;
62 * Constant returned by the <code>getAlignmentY</code> and
63 * <code>getAlignmentX</code> methods to indicate
64 * that the component wishes to be aligned to the center relative to
67 public static final float CENTER_ALIGNMENT = (float)0.5;
70 * Constant returned by the <code>getAlignmentY</code> method to indicate
71 * that the component wishes to be aligned to the top relative to
74 public static final float TOP_ALIGNMENT = (float)0.0;
77 * Constant returned by the <code>getAlignmentX</code> method to indicate
78 * that the component wishes to be aligned to the right relative to
81 public static final float RIGHT_ALIGNMENT = (float)1.0;
84 * Constant returned by the <code>getAlignmentX</code> method to indicate
85 * that the component wishes to be aligned to the left relative to
88 public static final float LEFT_ALIGNMENT = (float)0.0;
90 /* Make the treelock a String so that it can easily be identified
91 in debug dumps. We clone the String in order to avoid a conflict in
92 the unlikely event that some other package uses exactly the same string
94 static Object treeLock = new String("AWT_TREE_LOCK");
96 /* Serialized fields from the serialization spec. */
97 // FIXME: Default values?
108 boolean visible = true; // default (except for Window)
109 boolean enabled = true;
112 //DropTarget dropTarget;
115 boolean nameExplicitlySet;
118 boolean newEventsOnly;
119 long eventMask = AWTEvent.PAINT_EVENT_MASK;
120 PropertyChangeSupport changeSupport;
122 int componentSerializedDataVersion;
123 /* AccessibleContext accessibleContext; */
125 /* Anything else is non-serializable, and should be declared "transient". */
126 transient Container parent;
127 transient java.awt.peer.ComponentPeer peer;
129 transient ComponentListener componentListener;
130 transient FocusListener focusListener;
131 transient KeyListener keyListener;
132 transient MouseListener mouseListener;
133 transient MouseMotionListener mouseMotionListener;
134 transient InputMethodListener inputMethodListener;
135 transient HierarchyListener hierarchyListener;
136 transient HierarchyBoundsListener hierarchyBoundsListener;
138 transient ComponentOrientation orientation = ComponentOrientation.UNKNOWN;
141 * Default constructor for subclasses.
143 protected Component()
148 * Returns the name of this component.
150 * @return The name of this component.
152 public String getName()
154 if (name == null && !nameExplicitlySet)
155 name = generateName();
160 * Sets the name of this component to the specified name.
162 * @param name The new name of this component.
164 public void setName(String name)
166 nameExplicitlySet = true;
170 /** Subclasses should override this to return unique component names like
173 String generateName()
175 // Component is abstract.
180 * Returns the parent of this component.
182 * @return The parent of this component.
184 public Container getParent()
189 // Sets the peer for this component.
190 final void setPeer (ComponentPeer peer)
196 * Returns the native windowing system peer for this component.
198 * @return The peer for this component.
201 // Classpath's Gtk peers rely on this.
202 public java.awt.peer.ComponentPeer getPeer()
207 // FIXME: java.awt.dnd classes not yet implemented
209 public void setDropTarget(DropTarget dt)
211 this.dropTarget = dt;
214 public DropTarget getDropTarget()
221 public GraphicsConfiguration getGraphicsConfiguration()
223 return getGraphicsConfigurationImpl();
226 /** Implementation method that allows classes such as Canvas and
227 Window to override the graphics configuration without violating
228 the published API. */
229 GraphicsConfiguration getGraphicsConfigurationImpl()
233 GraphicsConfiguration config = peer.getGraphicsConfiguration();
239 return parent.getGraphicsConfiguration();
245 * Returns the object used for synchronization locks on this component
246 * when performing tree and layout functions.
248 * @return The synchronization lock for this component.
250 public final Object getTreeLock()
255 // The sync lock object for this component.
256 final void setTreeLock(Object tree_lock)
258 this.treeLock = tree_lock;
262 * Returns the toolkit in use for this component.
264 * @return The toolkit for this component.
266 public Toolkit getToolkit()
270 Toolkit tk = peer.getToolkit();
275 return parent.getToolkit ();
276 return Toolkit.getDefaultToolkit ();
280 * Tests whether or not this component is valid. A invalid component needs
281 * to have its layout redone.
283 * @return <code>true</code> if this component is valid, <code>false</code>
286 public boolean isValid()
292 public boolean isDisplayable()
295 return parent.isDisplayable();
300 * Tests whether or not this component is visible.
302 * @return <code>true</code> if the component is visible,
303 * <code>false</code> otherwise.
305 public boolean isVisible()
311 * Tests whether or not this component is actually being shown on
312 * the screen. This will be true if and only if it this component is
313 * visible and its parent components are all visible.
315 * @return <code>true</code> if the component is showing on the screen,
316 * <code>false</code> otherwise.
318 public boolean isShowing()
320 if (! visible || peer == null)
323 return parent == null ? true : parent.isShowing ();
327 * Tests whether or not this component is enabled.
329 * @return <code>true</code> if the component is enabled,
330 * <code>false</code> otherwise.
332 public boolean isEnabled()
338 * Enables or disables this component.
340 * @param enabled <code>true</code> to enable this component,
341 * <code>false</code> to disable it.
343 * @deprecated Deprecated in favor of <code>setEnabled()</code>.
345 public void setEnabled(boolean b)
353 * Enables this component.
355 * @deprecated Deprecated in favor of <code>setEnabled()</code>.
363 * Enables or disables this component.
365 * @param enabled <code>true</code> to enable this component,
366 * <code>false</code> to disable it.
368 * @deprecated Deprecated in favor of <code>setEnabled()</code>.
370 public void enable(boolean b)
376 * Disables this component.
378 * @deprecated Deprecated in favor of <code>setEnabled()</code>.
380 public void disable()
385 public boolean isDoubleBuffered()
391 public void enableInputMethods(boolean enable)
397 * Makes this component visible or invisible.
399 * @param visible <code>true</code> to make this component visible,
400 * </code>false</code> to make it invisible.
401 * @specnote Inspection by subclassing shows that Sun's implementation
402 * calls show(boolean) which then calls show() or hide(). It is
403 * the show() method that is overriden in subclasses like Window.
404 * We do the same to preserve compatibility for subclasses.
406 public void setVisible(boolean b)
414 * Makes this component visible on the screen.
416 * @deprecated Deprecated in favor of <code>setVisible()</code>.
424 * Makes this component visible or invisible.
426 * @param visible <code>true</code> to make this component visible,
427 * </code>false</code> to make it invisible.
429 * @deprecated Deprecated in favor of <code>setVisible()</code>.
431 public void show(boolean b)
437 * Hides this component so that it is no longer shown on the screen.
439 * @deprecated Deprecated in favor of <code>setVisible()</code>.
447 * Returns this component's foreground color.
449 * @return This component's foreground color.
451 public Color getForeground()
453 if (foreground != null)
456 return parent.getForeground();
461 * Sets this component's foreground color to the specified color.
463 * @param foreground_color The new foreground color.
465 public void setForeground(Color c)
468 peer.setForeground(c);
473 * Returns this component's background color.
475 * @return the background color of the component. null may be
476 * returned instead of the actual background color, if this
477 * method is called before the component is added to the
478 * component hierarchy.
480 public Color getBackground()
482 if (background != null)
485 return parent.getBackground();
490 * Sets this component's background color to the specified color.
492 * @param background_color The new background color
494 public void setBackground(Color c)
497 peer.setBackground(c);
502 * Returns the font in use for this component.
504 * @return The font for this component.
506 public Font getFont()
511 return parent.getFont();
516 * Sets the font for this component to the specified font.
518 * @param font The new font for this component.
520 public void setFont(Font f)
528 * Returns the locale for this component. If this component does not
529 * have a locale, the locale of the parent component is returned. If the
530 * component has no parent, the system default locale is returned.
532 * @return The locale for this component.
534 public Locale getLocale() throws IllegalComponentStateException
539 throw new IllegalComponentStateException
540 ("Component has no parent: Can not determine Locale");
541 return parent.getLocale();
545 * Sets the locale for this component to the specified locale.
547 * @param locale The new locale for this component.
549 public void setLocale(Locale l)
553 /* new writing/layout direction perhaps, or make more/less
554 room for localized text labels */
559 * Returns the color model of the device this componet is displayed on.
561 * @return This object's color model.
563 public ColorModel getColorModel()
565 GraphicsConfiguration config = getGraphicsConfiguration();
568 return config.getColorModel();
570 return getToolkit().getColorModel();
574 * Returns the location of this component's top left corner relative to
575 * its parent component.
577 * @return The location of this component.
579 public Point getLocation()
581 return new Point(x, y);
585 * Returns the location of this component's top left corner in screen
588 * @return The location of this component in screen coordinates.
590 public Point getLocationOnScreen()
593 throw new IllegalComponentStateException ("component not showing");
595 // We know peer != null here.
596 return peer.getLocationOnScreen ();
600 * Returns the location of this component's top left corner relative to
601 * its parent component.
603 * @return The location of this component.
605 * @deprecated This method is deprecated in favor of
606 * <code>getLocation()</code>.
608 public Point location()
610 return getLocation();
614 * Moves this component to the specified location. The coordinates are
615 * the new upper left corner of this component.
617 * @param x The new X coordinate of this component.
618 * @param y The new Y coordinate of this component.
620 public void setLocation (int x, int y)
622 if ((this.x == x) && (this.y == y))
630 peer.setBounds(x, y, width, height);
634 * Moves this component to the specified location. The coordinates are
635 * the new upper left corner of this component.
637 * @param x The new X coordinate of this component.
638 * @param y The new Y coordinate of this component.
640 * @deprecated Deprecated in favor for <code>setLocation</code>.
642 public void move(int x, int y)
648 * Moves this component to the specified location. The coordinates are
649 * the new upper left corner of this component.
651 * @param p New coordinates for this component.
653 public void setLocation(Point p)
655 setLocation(p.x, p.y);
659 * Returns the size of this object.
661 * @return The size of this object.
663 public Dimension getSize()
665 return new Dimension(width, height);
669 * Returns the size of this object.
671 * @return The size of this object.
673 * @deprecated This method is deprecated in favor of <code>getSize</code>.
675 public Dimension size()
681 * Sets the size of this component to the specified width and height.
683 * @param width The new width of this component.
684 * @param height The new height of this component.
686 public void setSize(int width, int height)
688 if ((this.width == width) && (this.height == height))
694 this.height = height;
696 peer.setBounds(x, y, width, height);
700 * Sets the size of this component to the specified value.
702 * @param width The new width of the component.
703 * @param height The new height of the component.
705 * @deprecated This method is deprecated in favor of <code>setSize</code>.
707 public void resize(int width, int height)
709 setSize(width, height);
713 * Sets the size of this component to the specified value.
715 * @param dim The new size of this component.
717 public void setSize(Dimension d)
719 setSize(d.width, d.height);
723 * Sets the size of this component to the specified value.
725 * @param dim The new size of this component.
727 * @deprecated This method is deprecated in favor of <code>setSize</code>.
729 public void resize(Dimension d)
731 setSize(d.width, d.height);
735 * Returns a bounding rectangle for this component. Note that the
736 * returned rectange is relative to this component's parent, not to
739 * @return The bounding rectangle for this component.
741 public Rectangle getBounds()
743 return new Rectangle (x, y, width, height);
747 * Returns a bounding rectangle for this component. Note that the
748 * returned rectange is relative to this component's parent, not to
751 * @return The bounding rectangle for this component.
753 * @deprecated Deprecated in favor of <code>getBounds()</code>.
755 public Rectangle bounds()
761 * Sets the bounding rectangle for this component to the specified
762 * values. Note that these coordinates are relative to the parent,
765 * @param x The X coordinate of the upper left corner of the rectangle.
766 * @param y The Y coordinate of the upper left corner of the rectangle.
767 * @param width The width of the rectangle.
768 * @param height The height of the rectangle.
770 public void setBounds(int x, int y, int w, int h)
786 peer.setBounds(x, y, w, h);
790 * Sets the bounding rectangle for this component to the specified
791 * values. Note that these coordinates are relative to the parent,
794 * @param x The X coordinate of the upper left corner of the rectangle.
795 * @param y The Y coordinate of the upper left corner of the rectangle.
796 * @param width The width of the rectangle.
797 * @param height The height of the rectangle.
799 * @deprecated This method is deprecated in favor of
800 * <code>setBounds(int, int, int, int)</code>.
802 public void reshape(int x, int y, int width, int height)
804 setBounds(x, y, width, height);
808 * Sets the bounding rectangle for this component to the specified
809 * rectangle. Note that these coordinates are relative to the parent,
812 * @param bounding_rectangle The new bounding rectangle.
814 public void setBounds(Rectangle r)
816 setBounds(r.x, r.y, r.width, r.height);
832 public int getWidth()
838 public int getHeight()
843 public Rectangle getBounds(Rectangle r)
847 r.width = this.width;
848 r.height = this.height;
852 public Dimension getSize(Dimension d)
854 d.width = this.width;
855 d.height = this.height;
859 public Point getLocation(Point p)
867 public boolean isOpaque()
869 return !isLightweight();
873 * Return whether the component is lightweight.
875 * @return true if component has a peer and and the peer is lightweight.
879 public boolean isLightweight()
881 return (peer != null) && (peer instanceof LightweightPeer);
885 * Returns the component's preferred size.
887 * @return The component's preferred size.
889 public Dimension getPreferredSize()
892 return new Dimension(width, height);
894 return peer.getPreferredSize();
898 * Returns the component's preferred size.
900 * @return The component's preferred size.
902 * @deprecated Deprecated in favor of <code>getPreferredSize()</code>.
904 public Dimension preferredSize()
906 return getPreferredSize();
910 * Returns the component's minimum size.
912 * @return The component's minimum size.
914 public Dimension getMinimumSize()
917 return new Dimension(width, height);
919 return peer.getMinimumSize();
923 * Returns the component's minimum size.
925 * @return The component's minimum size.
927 * @deprecated Deprecated in favor of <code>getMinimumSize()</code>
929 public Dimension minimumSize()
931 return getMinimumSize();
935 * Returns the component's maximum size.
937 * @return The component's maximum size.
939 public Dimension getMaximumSize()
941 return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
945 * Returns the preferred horizontal alignment of this component. The
946 * value returned will be one of the constants defined in this class.
948 * @return The preferred horizontal alignment of this component.
950 public float getAlignmentX()
952 return CENTER_ALIGNMENT;
956 * Returns the preferred vertical alignment of this component. The
957 * value returned will be one of the constants defined in this class.
959 * @return The preferred vertical alignment of this component.
961 public float getAlignmentY()
963 return CENTER_ALIGNMENT;
967 * Calls the layout manager to re-layout the component. This is called
968 * during validation of a container in most cases.
970 public void doLayout()
972 // nothing to do unless we're a container
976 * Calls the layout manager to re-layout the component. This is called
977 * during validation of a container in most cases.
979 * @deprecated This method is deprecated in favor of <code>doLayout()</code>.
987 * Called to ensure that the layout for this component is valid.
989 public void validate()
995 * Invalidates this component and all of its parent components. This will
996 * cause them to have their layout redone.
998 public void invalidate()
1002 if ((parent != null) && parent.valid)
1003 parent.invalidate ();
1007 * Returns a graphics object for this component. Returns <code>null</code>
1008 * if this component is not currently displayed on the screen.
1010 * @return A graphics object for this component.
1012 public Graphics getGraphics()
1016 Graphics gfx = peer.getGraphics();
1020 // create graphics for lightweight:
1021 Container parent = getParent();
1024 gfx = parent.getGraphics();
1025 Rectangle bounds = getBounds();
1026 gfx.setClip(bounds);
1027 gfx.translate(bounds.x, bounds.y);
1035 * Returns the font metrics for the specified font in this component.
1037 * @param font The font to retrieve metrics for.
1039 * @return The font metrics for the specified font.
1041 public FontMetrics getFontMetrics(Font font)
1044 return getToolkit().getFontMetrics(font);
1045 return peer.getFontMetrics (font);
1049 * Sets the cursor for this component to the specified cursor.
1051 * @param cursor The new cursor for this component.
1053 public void setCursor(Cursor cursor)
1055 this.cursor = cursor;
1057 peer.setCursor (cursor);
1061 * Returns the cursor for this component.
1063 * @return The cursor for this component.
1065 public Cursor getCursor()
1071 * Paints this component on the screen. The clipping region in the
1072 * graphics context will indicate the region that requires painting.
1074 * @param graphics The graphics context for this paint job.
1076 public void paint(Graphics g)
1081 * Updates this component. This method fills the component
1082 * with the background color, then sets the foreground color of the
1083 * specified graphics context to the foreground color of this component
1084 * and calls the <code>paint()</code> method.
1085 * // FIXME: What are the coords relative to?
1087 * @param graphics The graphics context for this update.
1089 public void update(Graphics g)
1095 * Paints this entire component, including any sub-components.
1097 * @param graphics The graphics context for this paint job.
1099 public void paintAll(Graphics g)
1110 * Repaint this entire component. The <code>update()</code> method
1111 * on this component will be called as soon as possible.
1112 * // FIXME: What are the coords relative to?
1114 public void repaint()
1116 repaint(0, 0, 0, getWidth(), getHeight());
1120 * Repaint this entire component. The <code>update()</code> method
1121 * on this component will be called in approximate the specified number
1123 * // FIXME: What are the coords relative to?
1125 * @param tm The number of milliseconds before this component should
1128 public void repaint(long tm)
1130 repaint(tm, 0, 0, getWidth(), getHeight());
1134 * Repaints the specified rectangular region within this component.
1135 * This <code>update</code> method on this component will be called as
1137 * // FIXME: What are the coords relative to?
1139 * @param x The X coordinate of the upper left of the region to repaint
1140 * @param y The Y coordinate of the upper left of the region to repaint
1141 * @param width The width of the region to repaint.
1142 * @param height The height of the region to repaint.
1144 public void repaint(int x, int y, int width, int height)
1146 repaint(0, x, y, width, height);
1150 * Repaints the specified rectangular region within this component.
1151 * This <code>update</code> method on this component will be called in
1152 * approximately the specified number of milliseconds.
1153 * // FIXME: What are the coords relative to?
1155 * @param tm The number of milliseconds before this component should
1157 * @param x The X coordinate of the upper left of the region to repaint
1158 * @param y The Y coordinate of the upper left of the region to repaint
1159 * @param width The width of the region to repaint.
1160 * @param height The height of the region to repaint.
1162 public void repaint(long tm, int x, int y, int width, int height)
1164 // Handle lightweight repainting by forwarding to native parent
1165 if (isLightweight() && (parent != null))
1168 parent.repaint(tm, x+getX(), y+getY(), width, height);
1173 peer.repaint(tm, x, y, width, height);
1177 * Prints this component. This method is
1178 * provided so that printing can be done in a different manner from
1179 * painting. However, the implementation in this class simply calls
1180 * the <code>paint()</code> method.
1182 * @param graphics The graphics context of the print device.
1184 public void print(Graphics g)
1190 * Prints this component, including all sub-components. This method is
1191 * provided so that printing can be done in a different manner from
1192 * painting. However, the implementation in this class simply calls
1193 * the <code>paintAll()</code> method.
1195 * @param graphics The graphics context of the print device.
1197 public void printAll(Graphics g)
1203 * Called when an image has changed so that this component is
1206 * @param image The image that has been updated.
1207 * @param flags Flags as specified in <code>ImageObserver</code>.
1208 * @param x The X coordinate
1209 * @param y The Y coordinate
1210 * @param width The width
1211 * @param height The height
1213 * @return <code>true</code> if the image has been fully loaded,
1214 * <code>false</code> otherwise.
1216 public boolean imageUpdate (Image img, int infoflags, int x, int y,
1224 * Creates an image from the specified producer.
1226 * @param producer The image procedure to create the image from.
1228 * @return The resulting image.
1230 public Image createImage(ImageProducer producer)
1232 return peer.createImage(producer);
1236 * Creates an image with the specified width and height for use in
1239 * @param width The width of the image.
1240 * @param height The height of the image.
1242 * @return The requested image.
1244 public Image createImage(int width, int height)
1246 return getGraphicsConfiguration().createCompatibleImage(width, height);
1250 * Prepares the specified image for rendering on this component.
1252 * @param image The image to prepare for rendering.
1253 * @param observer The image observer to notify of the status of the
1254 * image preparation.
1256 * @return <code>true</code> if the image is already fully prepared
1257 * for rendering, <code>false</code> otherwise.
1259 public boolean prepareImage(Image image, ImageObserver observer)
1261 return prepareImage(image, image.getWidth(observer),
1262 image.getHeight(observer), observer);
1266 * Prepares the specified image for rendering on this component at the
1267 * specified scaled width and height
1269 * @param image The image to prepare for rendering.
1270 * @param width The scaled width of the image.
1271 * @param height The scaled height of the image.
1272 * @param observer The image observer to notify of the status of the
1273 * image preparation.
1275 * @return <code>true</code> if the image is already fully prepared
1276 * for rendering, <code>false</code> otherwise.
1278 public boolean prepareImage(Image image, int width, int height,
1279 ImageObserver observer)
1281 return peer.prepareImage(image, width, height, observer);
1285 * Returns the status of the loading of the specified image. The value
1286 * returned will be those flags defined in <code>ImageObserver</code>.
1288 * @param image The image to check on.
1289 * @param observer The observer to be notified as the image loading
1292 * @return The image observer flags indicating the status of the load.
1294 public int checkImage(Image image, ImageObserver observer)
1296 return checkImage(image, image.getWidth(observer),
1297 image.getHeight(observer), observer);
1301 * Returns the status of the loading of the specified image. The value
1302 * returned will be those flags defined in <code>ImageObserver</code>.
1304 * @param image The image to check on.
1305 * @param width The scaled image width.
1306 * @param height The scaled image height.
1307 * @param observer The observer to be notified as the image loading
1310 * @return The image observer flags indicating the status of the load.
1312 public int checkImage (Image image, int width, int height,
1313 ImageObserver observer)
1316 return peer.checkImage (image, width, height, observer);
1317 return getToolkit ().checkImage (image, width, height, observer);
1321 * Tests whether or not the specified point is contained within this
1322 * component. Coordinates are relative to this component.
1324 * @param x The X coordinate of the point to test.
1325 * @param y The Y coordinate of the point to test.
1327 * @return <code>true</code> if the point is within this component,
1328 * <code>false</code> otherwise.
1330 public boolean contains (int x, int y)
1332 return (x >= 0) && (y >= 0) && (x < width) && (y < height);
1336 * Tests whether or not the specified point is contained within this
1337 * component. Coordinates are relative to this component.
1339 * @param x The X coordinate of the point to test.
1340 * @param y The Y coordinate of the point to test.
1342 * @return <code>true</code> if the point is within this component,
1343 * <code>false</code> otherwise.
1345 * @deprecated Deprecated in favor of <code>contains(int, int)</code>.
1347 public boolean inside(int x, int y)
1349 return contains(x,y);
1353 * Tests whether or not the specified point is contained within this
1354 * component. Coordinates are relative to this component.
1356 * @param point The point to test.
1358 * @return <code>true</code> if the point is within this component,
1359 * <code>false</code> otherwise.
1361 public boolean contains(Point p)
1363 return contains(p.x, p.y);
1367 * Returns the component occupying the position (x,y). This will either
1368 * be this component, an immediate child component, or <code>null</code>
1369 * if neither of the first two occupies the specified location.
1371 * @param x The X coordinate to search for components at.
1372 * @param y The Y coordinate to search for components at.
1374 * @return The component at the specified location, for <code>null</code>
1377 public Component getComponentAt(int x, int y)
1385 * Returns the component occupying the position (x,y). This will either
1386 * be this component, an immediate child component, or <code>null</code>
1387 * if neither of the first two occupies the specified location.
1389 * @param x The X coordinate to search for components at.
1390 * @param y The Y coordinate to search for components at.
1392 * @return The component at the specified location, for <code>null</code>
1395 * @deprecated The method is deprecated in favor of
1396 * <code>getComponentAt()</code>.
1398 public Component locate(int x, int y)
1400 return getComponentAt(x, y);
1404 * Returns the component occupying the specified point This will either
1405 * be this component, an immediate child component, or <code>null</code>
1406 * if neither of the first two occupies the specified location.
1408 * @param point The point to search for components at.
1410 * @return The component at the specified location, for <code>null</code>
1413 public Component getComponentAt(Point p)
1415 return getComponentAt(p.x, p.y);
1419 * AWT 1.0 event dispatcher.
1421 * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
1423 public void deliverEvent(Event e)
1427 /** Forward AWT events to processEvent() if:
1428 * - Events have been enabled for this type of event via enableEvents(),
1430 * - There is at least one registered listener for this type of event
1432 * @param event The event to dispatch
1434 * @specnote This method is final, but we need to be able to
1435 * override it in order to handle other event types in our
1436 * subclasses. The solution is to define a second, non-final
1437 * method - dispatchEventImpl() - to actually do the work.
1438 * Investigations with Thread.dumpStack() on the dispatch thread
1439 * in JDK 1.3 show Sun's implementation is doing the same
1442 public final void dispatchEvent(AWTEvent e)
1444 dispatchEventImpl(e);
1446 /* Give the peer a chance to handle the event. */
1448 peer.handleEvent(e);
1451 void dispatchEventImpl(AWTEvent e)
1453 // Make use of event id's in order to avoid multiple instanceof tests.
1454 if (e.id <= ComponentEvent.COMPONENT_LAST
1455 && e.id >= ComponentEvent.COMPONENT_FIRST
1456 && (componentListener != null
1457 || (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0))
1459 else if (e.id <= KeyEvent.KEY_LAST
1460 && e.id >= KeyEvent.KEY_FIRST
1461 && (keyListener != null
1462 || (eventMask & AWTEvent.KEY_EVENT_MASK) != 0))
1464 else if (e.id <= MouseEvent.MOUSE_LAST
1465 && e.id >= MouseEvent.MOUSE_FIRST
1466 && (mouseListener != null
1467 || mouseMotionListener != null
1468 || (eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0))
1470 else if (e.id <= FocusEvent.FOCUS_LAST
1471 && e.id >= FocusEvent.FOCUS_FIRST
1472 && (focusListener != null
1473 || (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0))
1475 else if (e.id <= InputMethodEvent.INPUT_METHOD_LAST
1476 && e.id >= InputMethodEvent.INPUT_METHOD_FIRST
1477 && (inputMethodListener != null
1478 || (eventMask & AWTEvent.INPUT_METHOD_EVENT_MASK) != 0))
1480 else if (e.id <= HierarchyEvent.HIERARCHY_LAST
1481 && e.id >= HierarchyEvent.HIERARCHY_FIRST
1482 && (hierarchyListener != null
1483 || hierarchyBoundsListener != null
1484 || (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0))
1486 else if (e.id <= PaintEvent.PAINT_LAST
1487 && e.id >= PaintEvent.PAINT_FIRST
1488 && (eventMask & AWTEvent.PAINT_EVENT_MASK) != 0)
1493 * AWT 1.0 event dispatcher.
1495 * @deprecated Deprecated in favor of <code>dispatchEvent()</code>.
1497 public boolean postEvent(Event e)
1503 * Adds the specified listener to this component.
1505 * @param listener The new listener to add.
1507 public synchronized void addComponentListener(ComponentListener l)
1509 componentListener = AWTEventMulticaster.add(componentListener, l);
1510 if (componentListener != null)
1511 enableEvents(AWTEvent.COMPONENT_EVENT_MASK);
1515 * Removes the specified listener from the component.
1517 * @param listener The listener to remove.
1519 public synchronized void removeComponentListener(ComponentListener l)
1521 componentListener = AWTEventMulticaster.remove(componentListener, l);
1525 * Adds the specified listener to this component.
1527 * @param listener The new listener to add.
1529 public synchronized void addFocusListener(FocusListener l)
1531 focusListener = AWTEventMulticaster.add(focusListener, l);
1532 if (focusListener != null)
1533 enableEvents(AWTEvent.FOCUS_EVENT_MASK);
1537 * Removes the specified listener from the component.
1539 * @param listener The listener to remove.
1541 public synchronized void removeFocusListener(FocusListener l)
1543 focusListener = AWTEventMulticaster.remove(focusListener, l);
1547 public synchronized void addHierarchyListener(HierarchyListener l)
1549 hierarchyListener = AWTEventMulticaster.add(hierarchyListener, l);
1550 if (hierarchyListener != null)
1551 enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);
1555 public synchronized void removeHierarchyListener(HierarchyListener l)
1557 hierarchyListener = AWTEventMulticaster.remove(hierarchyListener, l);
1561 public synchronized void addHierarchyBoundsListener(HierarchyBoundsListener l)
1563 hierarchyBoundsListener =
1564 AWTEventMulticaster.add(hierarchyBoundsListener, l);
1565 if (hierarchyBoundsListener != null)
1566 enableEvents(AWTEvent.HIERARCHY_EVENT_MASK);
1570 public synchronized void
1571 removeHierarchyBoundsListener(HierarchyBoundsListener l)
1573 hierarchyBoundsListener =
1574 AWTEventMulticaster.remove(hierarchyBoundsListener, l);
1578 * Adds the specified listener to this component.
1580 * @param listener The new listener to add.
1582 public synchronized void addKeyListener(KeyListener l)
1584 keyListener = AWTEventMulticaster.add(keyListener, l);
1585 if (keyListener != null)
1586 enableEvents(AWTEvent.KEY_EVENT_MASK);
1590 * Removes the specified listener from the component.
1592 * @param listener The listener to remove.
1594 public synchronized void removeKeyListener(KeyListener l)
1596 keyListener = AWTEventMulticaster.remove(keyListener, l);
1600 * Adds the specified listener to this component.
1602 * @param listener The new listener to add.
1604 public synchronized void addMouseListener(MouseListener l)
1606 mouseListener = AWTEventMulticaster.add(mouseListener, l);
1607 if (mouseListener != null)
1608 enableEvents(AWTEvent.MOUSE_EVENT_MASK);
1612 * Removes the specified listener from the component.
1614 * @param listener The listener to remove.
1616 public synchronized void removeMouseListener(MouseListener l)
1618 mouseListener = AWTEventMulticaster.remove(mouseListener, l);
1622 * Adds the specified listener to this component.
1624 * @param listener The new listener to add.
1626 public synchronized void addMouseMotionListener(MouseMotionListener l)
1628 mouseMotionListener = AWTEventMulticaster.add(mouseMotionListener, l);
1629 if (mouseMotionListener != null)
1630 enableEvents(AWTEvent.MOUSE_EVENT_MASK);
1634 * Removes the specified listener from the component.
1636 * @param listener The listener to remove.
1638 public synchronized void removeMouseMotionListener(MouseMotionListener l)
1640 mouseMotionListener = AWTEventMulticaster.remove(mouseMotionListener, l);
1644 public synchronized void addInputMethodListener(InputMethodListener l)
1646 inputMethodListener = AWTEventMulticaster.add(inputMethodListener, l);
1647 if (inputMethodListener != null)
1648 enableEvents(AWTEvent.INPUT_METHOD_EVENT_MASK);
1652 public synchronized void removeInputMethodListener(InputMethodListener l)
1654 inputMethodListener = AWTEventMulticaster.remove(inputMethodListener, l);
1657 /** Returns all registered EventListers of the given listenerType.
1658 * listenerType must be a subclass of EventListener, or a
1659 * ClassClassException is thrown.
1662 public EventListener[] getListeners(Class listenerType)
1664 if (listenerType == ComponentListener.class)
1665 return getListenersImpl(listenerType, componentListener);
1666 else if (listenerType == FocusListener.class)
1667 return getListenersImpl(listenerType, focusListener);
1668 else if (listenerType == KeyListener.class)
1669 return getListenersImpl(listenerType, keyListener);
1670 else if (listenerType == MouseListener.class)
1671 return getListenersImpl(listenerType, mouseListener);
1672 else if (listenerType == MouseMotionListener.class)
1673 return getListenersImpl(listenerType, mouseMotionListener);
1674 else if (listenerType == InputMethodListener.class)
1675 return getListenersImpl(listenerType, inputMethodListener);
1676 else if (listenerType == HierarchyListener.class)
1677 return getListenersImpl(listenerType, hierarchyListener);
1678 else if (listenerType == HierarchyBoundsListener.class)
1679 return getListenersImpl(listenerType, hierarchyBoundsListener);
1681 return getListenersImpl(listenerType, null);
1684 static EventListener[] getListenersImpl(Class listenerType, EventListener el)
1686 if (! EventListener.class.isAssignableFrom(listenerType))
1687 throw new ClassCastException();
1689 Vector v = new Vector();
1691 getListenerList (el, v);
1692 EventListener[] el_a = (EventListener[]) Array.newInstance(listenerType,
1698 static void getListenerList(EventListener el, Vector v)
1700 if (el instanceof AWTEventMulticaster)
1702 AWTEventMulticaster mc = (AWTEventMulticaster) el;
1703 getListenerList(mc.a, v);
1704 getListenerList(mc.b, v);
1710 // The input method framework is currently unimplemented.
1711 // /** @since 1.2 */
1713 //public InputMethodRequests getInputMethodRequests()
1715 // /** @since 1.2 */
1717 // public InputContext getInputContext()
1720 * Enables the specified events. The events to enable are specified
1721 * by OR-ing together the desired masks from <code>AWTEvent</code>.
1723 * Events are enabled by default when a listener is attached to the
1724 * component for that event type. This method can be used by subclasses
1725 * to ensure the delivery of a specified event regardless of whether
1726 * or not a listener is attached.
1728 * @param enable_events The desired events to enable.
1730 protected final void enableEvents(long eventsToEnable)
1732 eventMask |= eventsToEnable;
1733 // TODO: Unlike Sun's implementation, I think we should try and
1734 // enable/disable events at the peer (gtk/X) level. This will avoid
1735 // clogging the event pipeline with useless mousemove events that
1736 // we arn't interested in, etc. This will involve extending the peer
1737 // interface, but thats okay because the peer interfaces have been
1738 // deprecated for a long time, and no longer feature in the
1739 // API specification at all.
1741 if (isLightweight() && (parent != null))
1742 parent.enableEvents(eventsToEnable);
1743 else if (peer != null)
1744 peer.setEventMask (eventMask);
1748 * Disables the specified events. The events to disable are specified
1749 * by OR-ing together the desired masks from <code>AWTEvent</code>.
1751 * @param disable_events The desired events to disable.
1753 protected final void disableEvents(long eventsToDisable)
1755 eventMask &= ~eventsToDisable;
1756 // forward new event mask to peer?
1759 /** coalesceEvents is called by the EventQueue if two events with the same
1760 * event id are queued. Returns a new combined event, or null if no
1761 * combining is done.
1763 protected AWTEvent coalesceEvents(AWTEvent existingEvent, AWTEvent newEvent)
1765 switch (existingEvent.id)
1767 case MouseEvent.MOUSE_MOVED:
1768 case MouseEvent.MOUSE_DRAGGED:
1769 // Just drop the old (intermediate) event and return the new one.
1771 case PaintEvent.PAINT:
1772 case PaintEvent.UPDATE:
1773 return coalescePaintEvents((PaintEvent) existingEvent,
1774 (PaintEvent) newEvent);
1780 * Coalesce paint events. Current heuristic is: Merge if the union of
1781 * areas is less than twice that of the sum of the areas. The X server
1782 * tend to create a lot of paint events that are adjacent but not
1787 * | +-----+ ...will be merged
1793 * +---------------+--+
1794 * | | | ...will not be merged
1795 * +---------------+ |
1804 private PaintEvent coalescePaintEvents(PaintEvent queuedEvent,
1805 PaintEvent newEvent)
1807 Rectangle r1 = queuedEvent.getUpdateRect();
1808 Rectangle r2 = newEvent.getUpdateRect();
1809 Rectangle union = r1.union(r2);
1811 int r1a = r1.width * r1.height;
1812 int r2a = r2.width * r2.height;
1813 int ua = union.width * union.height;
1815 if (ua > (r1a+r2a)*2)
1817 /* The 2 factor should maybe be reconsidered. Perhaps 3/2
1820 newEvent.setUpdateRect(union);
1825 * Processes the specified event. In this class, this method simply
1826 * calls one of the more specific event handlers.
1828 * @param event The event to process.
1830 protected void processEvent(AWTEvent e)
1833 /* Note: the order of these if statements are
1834 important. Subclasses must be checked first. Eg. MouseEvent
1835 must be checked before ComponentEvent, since a MouseEvent
1836 object is also an instance of a ComponentEvent. */
1838 if (e instanceof FocusEvent)
1839 processFocusEvent((FocusEvent) e);
1840 else if (e instanceof PaintEvent)
1841 processPaintEvent((PaintEvent) e);
1842 else if (e instanceof MouseEvent)
1844 if (e.id == MouseEvent.MOUSE_MOVED
1845 || e.id == MouseEvent.MOUSE_DRAGGED)
1846 processMouseMotionEvent((MouseEvent) e);
1848 processMouseEvent((MouseEvent) e);
1850 else if (e instanceof ComponentEvent)
1851 processComponentEvent((ComponentEvent) e);
1852 else if (e instanceof KeyEvent)
1853 processKeyEvent((KeyEvent) e);
1854 else if (e instanceof InputMethodEvent)
1855 processInputMethodEvent((InputMethodEvent) e);
1856 else if (e instanceof HierarchyEvent)
1858 if (e.id == HierarchyEvent.HIERARCHY_CHANGED)
1859 processHierarchyEvent((HierarchyEvent) e);
1861 processHierarchyBoundsEvent((HierarchyEvent) e);
1866 * Called when a component event is dispatched and component events are
1867 * enabled. This method passes the event along to any listeners
1868 * that are attached.
1870 * @param event The <code>ComponentEvent</code> to process.
1872 protected void processComponentEvent(ComponentEvent e)
1874 if (componentListener == null)
1878 case ComponentEvent.COMPONENT_HIDDEN:
1879 componentListener.componentHidden(e);
1882 case ComponentEvent.COMPONENT_MOVED:
1883 componentListener.componentMoved(e);
1886 case ComponentEvent.COMPONENT_RESIZED:
1887 componentListener.componentResized(e);
1890 case ComponentEvent.COMPONENT_SHOWN:
1891 componentListener.componentShown(e);
1897 * Called when a focus event is dispatched and component events are
1898 * enabled. This method passes the event along to any listeners
1899 * that are attached.
1901 * @param event The <code>FocusEvent</code> to process.
1903 protected void processFocusEvent(FocusEvent e)
1905 if (focusListener == null)
1909 case FocusEvent.FOCUS_GAINED:
1910 focusListener.focusGained(e);
1912 case FocusEvent.FOCUS_LOST:
1913 focusListener.focusLost(e);
1919 * Called when a key event is dispatched and component events are
1920 * enabled. This method passes the event along to any listeners
1921 * that are attached.
1923 * @param event The <code>KeyEvent</code> to process.
1925 protected void processKeyEvent(KeyEvent e)
1927 if (keyListener == null)
1931 case KeyEvent.KEY_PRESSED:
1932 keyListener.keyPressed(e);
1934 case KeyEvent.KEY_RELEASED:
1935 keyListener.keyReleased(e);
1937 case KeyEvent.KEY_TYPED:
1938 keyListener.keyTyped(e);
1944 * Called when a regular mouse event is dispatched and component events are
1945 * enabled. This method passes the event along to any listeners
1946 * that are attached.
1948 * @param event The <code>MouseEvent</code> to process.
1950 protected void processMouseEvent(MouseEvent e)
1952 if (mouseListener == null)
1956 case MouseEvent.MOUSE_CLICKED:
1957 mouseListener.mouseClicked(e);
1959 case MouseEvent.MOUSE_ENTERED:
1960 mouseListener.mouseEntered(e);
1962 case MouseEvent.MOUSE_EXITED:
1963 mouseListener.mouseExited(e);
1965 case MouseEvent.MOUSE_PRESSED:
1966 mouseListener.mousePressed(e);
1968 case MouseEvent.MOUSE_RELEASED:
1969 mouseListener.mouseReleased(e);
1975 * Called when a mouse motion event is dispatched and component events are
1976 * enabled. This method passes the event along to any listeners
1977 * that are attached.
1979 * @param event The <code>MouseMotionEvent</code> to process.
1981 protected void processMouseMotionEvent(MouseEvent e)
1983 if (mouseMotionListener == null)
1987 case MouseEvent.MOUSE_DRAGGED:
1988 mouseMotionListener.mouseDragged(e);
1990 case MouseEvent.MOUSE_MOVED:
1991 mouseMotionListener.mouseMoved(e);
1997 protected void processInputMethodEvent(InputMethodEvent e)
1999 if (inputMethodListener == null)
2003 case InputMethodEvent.CARET_POSITION_CHANGED:
2004 inputMethodListener.caretPositionChanged(e);
2006 case InputMethodEvent.INPUT_METHOD_TEXT_CHANGED:
2007 inputMethodListener.inputMethodTextChanged(e);
2013 protected void processHierarchyEvent(HierarchyEvent e)
2015 if (hierarchyListener == null)
2017 if (e.id == HierarchyEvent.HIERARCHY_CHANGED)
2018 hierarchyListener.hierarchyChanged(e);
2022 protected void processHierarchyBoundsEvent(HierarchyEvent e)
2024 if (hierarchyBoundsListener == null)
2028 case HierarchyEvent.ANCESTOR_MOVED:
2029 hierarchyBoundsListener.ancestorMoved(e);
2031 case HierarchyEvent.ANCESTOR_RESIZED:
2032 hierarchyBoundsListener.ancestorResized(e);
2037 private void processPaintEvent(PaintEvent event)
2039 // Can't do graphics without peer
2043 Graphics gfx = getGraphics();
2044 Shape clip = event.getUpdateRect();
2049 case PaintEvent.PAINT:
2052 case PaintEvent.UPDATE:
2056 throw new IllegalArgumentException("unknown paint event");
2061 * AWT 1.0 event processor.
2063 * @deprecated Deprecated in favor of <code>processEvent</code>.
2065 public boolean handleEvent(Event evt)
2071 * AWT 1.0 mouse event.
2073 * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
2075 public boolean mouseDown(Event evt, int x, int y)
2081 * AWT 1.0 mouse event.
2083 * @deprecated Deprecated in favor of <code>processMouseMotionEvent()</code>.
2085 public boolean mouseDrag(Event evt, int x, int y)
2091 * AWT 1.0 mouse event.
2093 * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
2095 public boolean mouseUp(Event evt, int x, int y)
2101 * AWT 1.0 mouse event.
2103 * @deprecated Deprecated in favor of <code>processMouseMotionEvent()</code>.
2105 public boolean mouseMove(Event evt, int x, int y)
2111 * AWT 1.0 mouse event.
2113 * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
2115 public boolean mouseEnter(Event evt, int x, int y)
2121 * AWT 1.0 mouse event.
2123 * @deprecated Deprecated in favor of <code>processMouseEvent()</code>.
2125 public boolean mouseExit(Event evt, int x, int y)
2131 * AWT 1.0 key press event.
2133 * @deprecated Deprecated in favor of <code>processKeyEvent</code>.
2135 public boolean keyDown(Event evt, int key)
2141 * AWT 1.0 key press event.
2143 * @deprecated Deprecated in favor of <code>processKeyEvent</code>.
2145 public boolean keyUp(Event evt, int key)
2151 * AWT 1.0 action event processor.
2153 * @deprecated Deprecated in favor of the <code>ActionListener</code>
2156 public boolean action(Event evt, Object what)
2162 * Called to inform this component it has been added to a container.
2163 * A native peer - if any - is created at this time. This method is
2164 * called automatically by the AWT system and should not be called by
2167 public void addNotify()
2170 peer = getToolkit().createComponent(this);
2172 /* Now that all the children has gotten their peers, we should
2173 have the event mask needed for this component and its
2174 lightweight subcomponents. */
2176 peer.setEventMask(eventMask);
2178 /* We do not invalidate here, but rather leave that job up to
2179 the peer. For efficiency, the peer can choose not to
2180 invalidate if it is happy with the current dimensions,
2185 * Called to inform this component is has been removed from its
2186 * container. Its native peer - if any - is destroyed at this time.
2187 * This method is called automatically by the AWT system and should
2188 * not be called by user level code.
2190 public void removeNotify()
2198 public boolean gotFocus(Event evt, Object what)
2204 public boolean lostFocus(Event evt, Object what)
2210 * Tests whether or not this component is in the group that can
2211 * be traversed using the keyboard traversal mechanism (such as the TAB
2214 * @return <code>true</code> if the component is traversed via the TAB
2215 * key, <code>false</code> otherwise.
2217 public boolean isFocusTraversable()
2219 return enabled && visible && (peer == null || peer.isFocusTraversable ());
2223 * Requests that this component be given focus. The <code>gotFocus()</code>
2224 * method on this event will be called when and if this request was
2227 public void requestFocus()
2229 // If there's no peer then this component can't get the focus. We
2230 // treat it as a silent rejection of the request.
2232 peer.requestFocus ();
2235 // This method is used to implement transferFocus().
2236 // CHILD is the child making the request.
2237 // This is overridden by Container; when called for an ordinary
2238 // component there is no child and so we always return null.
2239 Component findNextFocusComponent (Component child)
2245 * Transfers focus to the next component in the focus traversal order.
2247 public void transferFocus()
2251 next = findNextFocusComponent (null);
2253 next = parent.findNextFocusComponent (this);
2254 if (next != null && next != this)
2255 next.requestFocus ();
2259 * AWT 1.0 focus event processor.
2261 * @deprecated Deprecated in favor of <code>transferFocus()</code>.
2263 public void nextFocus()
2269 public boolean hasFocus()
2275 * Adds the specified popup menu to this component.
2277 * @param menu The popup menu to be added.
2279 public synchronized void add(PopupMenu popup)
2282 popups = new Vector();
2283 popups.addElement(popup);
2287 * Removes the specified popup menu from this component.
2289 * @param menu The popup menu to remove.
2291 public synchronized void remove(MenuComponent popup)
2293 popups.removeElement(popup);
2297 * Returns a debugging string representing this component.
2299 * @return A string representing this component.
2301 protected String paramString()
2303 StringBuffer param = new StringBuffer();
2304 String name = getName();
2310 param.append(width);
2312 param.append(height);
2319 param.append(",invalid");
2321 param.append(",invisible");
2323 param.append(",disabled");
2325 param.append(",translucent");
2326 if (isDoubleBuffered())
2327 param.append(",doublebuffered");
2329 return param.toString();
2333 * Returns a string representation of this component.
2335 * @return A string representation of this component
2337 public String toString()
2339 return this.getClass().getName() + "[" + paramString() + "]";
2343 * Prints a listing of this component to the standard output.
2347 list (System.out, 0);
2351 * Prints a listing of this component to the specified print stream.
2353 * @param stream The <code>PrintStream</code> to print to.
2355 public void list (PrintStream out)
2361 * Prints a listing of this component to the specified print stream,
2362 * starting at the specified indentation point.
2364 * @param stream The <code>PrintStream</code> to print to.
2365 * @param indent The indentation point.
2367 public void list (PrintStream out, int indent)
2369 for (int i = 0; i < indent; ++i)
2371 out.println (toString ());
2375 * Prints a listing of this component to the specified print writer.
2377 * @param writer The <code>PrintWrinter</code> to print to.
2379 public void list (PrintWriter out)
2385 * Prints a listing of this component to the specified print writer,
2386 * starting at the specified indentation point.
2388 * @param writer The <code>PrintWriter</code> to print to.
2389 * @param indent The indentation point.
2391 public void list (PrintWriter out, int indent)
2393 for (int i = 0; i < indent; ++i)
2395 out.println (toString ());
2398 public void addPropertyChangeListener(PropertyChangeListener listener)
2400 if (changeSupport == null)
2401 changeSupport = new PropertyChangeSupport(this);
2402 changeSupport.addPropertyChangeListener(listener);
2405 public void removePropertyChangeListener(PropertyChangeListener listener)
2407 if (changeSupport != null)
2408 changeSupport.removePropertyChangeListener(listener);
2411 public void addPropertyChangeListener(String propertyName,
2412 PropertyChangeListener listener)
2414 if (changeSupport == null)
2415 changeSupport = new PropertyChangeSupport(this);
2416 changeSupport.addPropertyChangeListener(propertyName, listener);
2419 public void removePropertyChangeListener(String propertyName,
2420 PropertyChangeListener listener)
2422 if (changeSupport != null)
2423 changeSupport.removePropertyChangeListener(propertyName, listener);
2426 protected void firePropertyChange(String propertyName, Object oldValue,
2429 if (changeSupport != null)
2430 changeSupport.firePropertyChange(propertyName, oldValue, newValue);
2433 public void setComponentOrientation(ComponentOrientation o)
2438 public ComponentOrientation getComponentOrientation()
2444 public AccessibleContext getAccessibleContext()
2446 return accessibleContext;
2451 * AWT 1.0 focus event processor.
2453 * @deprecated Deprecated in favor of <code>processFocusEvent</code>.
2456 gotFocus(Event event, Object what)
2463 * AWT 1.0 focus event processor.
2465 * @deprecated Deprecated in favor of <code>processFocusEvent</code>.
2468 lostFocus(Event event, Object what)