src/share/classes/java/awt/Component.java

Print this page




1058 
1059     // NOTE: This method may be called by privileged threads.
1060     //       This functionality is implemented in a package-private method
1061     //       to insure that it cannot be overridden by client subclasses.
1062     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
1063     final Container getParent_NoClientCode() {
1064         return parent;
1065     }
1066 
1067     // This method is overridden in the Window class to return null,
1068     //    because the parent field of the Window object contains
1069     //    the owner of the window, not its parent.
1070     Container getContainer() {
1071         return getParent_NoClientCode();
1072     }
1073 
1074     /**
1075      * @deprecated As of JDK version 1.1,
1076      * programs should not directly manipulate peers;
1077      * replaced by <code>boolean isDisplayable()</code>.

1078      */
1079     @Deprecated
1080     public ComponentPeer getPeer() {
1081         return peer;
1082     }
1083 
1084     /**
1085      * Associate a <code>DropTarget</code> with this component.
1086      * The <code>Component</code> will receive drops only if it
1087      * is enabled.
1088      *
1089      * @see #isEnabled
1090      * @param dt The DropTarget
1091      */
1092 
1093     public synchronized void setDropTarget(DropTarget dt) {
1094         if (dt == dropTarget || (dropTarget != null && dropTarget.equals(dt)))
1095             return;
1096 
1097         DropTarget old;


1115         if ((dropTarget = dt) != null) {
1116             try {
1117                 dropTarget.setComponent(this);
1118                 if (peer != null) dropTarget.addNotify(peer);
1119             } catch (IllegalArgumentException iae) {
1120                 if (old != null) {
1121                     try {
1122                         old.setComponent(this);
1123                         if (peer != null) dropTarget.addNotify(peer);
1124                     } catch (IllegalArgumentException iae1) {
1125                         // ignore it!
1126                     }
1127                 }
1128             }
1129         }
1130     }
1131 
1132     /**
1133      * Gets the <code>DropTarget</code> associated with this
1134      * <code>Component</code>.


1135      */
1136 
1137     public synchronized DropTarget getDropTarget() { return dropTarget; }
1138 
1139     /**
1140      * Gets the <code>GraphicsConfiguration</code> associated with this
1141      * <code>Component</code>.
1142      * If the <code>Component</code> has not been assigned a specific
1143      * <code>GraphicsConfiguration</code>,
1144      * the <code>GraphicsConfiguration</code> of the
1145      * <code>Component</code> object's top-level container is
1146      * returned.
1147      * If the <code>Component</code> has been created, but not yet added
1148      * to a <code>Container</code>, this method returns <code>null</code>.
1149      *
1150      * @return the <code>GraphicsConfiguration</code> used by this
1151      *          <code>Component</code> or <code>null</code>
1152      * @since 1.3
1153      */
1154     public GraphicsConfiguration getGraphicsConfiguration() {


1481         if (!enabled) {
1482             synchronized (getTreeLock()) {
1483                 enabled = true;
1484                 ComponentPeer peer = this.peer;
1485                 if (peer != null) {
1486                     peer.setEnabled(true);
1487                     if (visible) {
1488                         updateCursorImmediately();
1489                     }
1490                 }
1491             }
1492             if (accessibleContext != null) {
1493                 accessibleContext.firePropertyChange(
1494                                                      AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
1495                                                      null, AccessibleState.ENABLED);
1496             }
1497         }
1498     }
1499 
1500     /**





1501      * @deprecated As of JDK version 1.1,
1502      * replaced by <code>setEnabled(boolean)</code>.
1503      */
1504     @Deprecated
1505     public void enable(boolean b) {
1506         if (b) {
1507             enable();
1508         } else {
1509             disable();
1510         }
1511     }
1512 
1513     /**
1514      * @deprecated As of JDK version 1.1,
1515      * replaced by <code>setEnabled(boolean)</code>.
1516      */
1517     @Deprecated
1518     public void disable() {
1519         if (enabled) {
1520             KeyboardFocusManager.clearMostRecentFocusOwner(this);


1639                     }
1640                     updateCursorImmediately();
1641                 }
1642 
1643                 if (componentListener != null ||
1644                     (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ||
1645                     Toolkit.enabledOnToolkit(AWTEvent.COMPONENT_EVENT_MASK)) {
1646                     ComponentEvent e = new ComponentEvent(this,
1647                                                           ComponentEvent.COMPONENT_SHOWN);
1648                     Toolkit.getEventQueue().postEvent(e);
1649                 }
1650             }
1651             Container parent = this.parent;
1652             if (parent != null) {
1653                 parent.invalidate();
1654             }
1655         }
1656     }
1657 
1658     /**





1659      * @deprecated As of JDK version 1.1,
1660      * replaced by <code>setVisible(boolean)</code>.
1661      */
1662     @Deprecated
1663     public void show(boolean b) {
1664         if (b) {
1665             show();
1666         } else {
1667             hide();
1668         }
1669     }
1670 
1671     boolean containsFocus() {
1672         return isFocusOwner();
1673     }
1674 
1675     void clearMostRecentFocusOwnerOnHide() {
1676         KeyboardFocusManager.clearMostRecentFocusOwner(this);
1677     }
1678 


2051                 // lightweight component location needs to be translated
2052                 // relative to a native component.
2053                 Container host = getNativeContainer();
2054                 Point pt = host.peer.getLocationOnScreen();
2055                 for(Component c = this; c != host; c = c.getParent()) {
2056                     pt.x += c.x;
2057                     pt.y += c.y;
2058                 }
2059                 return pt;
2060             } else {
2061                 Point pt = peer.getLocationOnScreen();
2062                 return pt;
2063             }
2064         } else {
2065             throw new IllegalComponentStateException("component must be showing on the screen to determine its location");
2066         }
2067     }
2068 
2069 
2070     /**



2071      * @deprecated As of JDK version 1.1,
2072      * replaced by <code>getLocation()</code>.
2073      */
2074     @Deprecated
2075     public Point location() {
2076         return location_NoClientCode();
2077     }
2078 
2079     private Point location_NoClientCode() {
2080         return new Point(x, y);
2081     }
2082 
2083     /**
2084      * Moves this component to a new location. The top-left corner of
2085      * the new location is specified by the <code>x</code> and <code>y</code>
2086      * parameters in the coordinate space of this component's parent.
2087      * <p>
2088      * This method changes layout-related information, and therefore,
2089      * invalidates the component hierarchy.
2090      *
2091      * @param x the <i>x</i>-coordinate of the new location's
2092      *          top-left corner in the parent's coordinate space
2093      * @param y the <i>y</i>-coordinate of the new location's
2094      *          top-left corner in the parent's coordinate space
2095      * @see #getLocation
2096      * @see #setBounds
2097      * @see #invalidate
2098      * @since JDK1.1
2099      */
2100     public void setLocation(int x, int y) {
2101         move(x, y);
2102     }
2103 
2104     /**







2105      * @deprecated As of JDK version 1.1,
2106      * replaced by <code>setLocation(int, int)</code>.
2107      */
2108     @Deprecated
2109     public void move(int x, int y) {
2110         synchronized(getTreeLock()) {
2111             setBoundsOp(ComponentPeer.SET_LOCATION);
2112             setBounds(x, y, width, height);
2113         }
2114     }
2115 
2116     /**
2117      * Moves this component to a new location. The top-left corner of
2118      * the new location is specified by point <code>p</code>. Point
2119      * <code>p</code> is given in the parent's coordinate space.
2120      * <p>
2121      * This method changes layout-related information, and therefore,
2122      * invalidates the component hierarchy.
2123      *
2124      * @param p the point defining the top-left corner


2133         setLocation(p.x, p.y);
2134     }
2135 
2136     /**
2137      * Returns the size of this component in the form of a
2138      * <code>Dimension</code> object. The <code>height</code>
2139      * field of the <code>Dimension</code> object contains
2140      * this component's height, and the <code>width</code>
2141      * field of the <code>Dimension</code> object contains
2142      * this component's width.
2143      * @return a <code>Dimension</code> object that indicates the
2144      *          size of this component
2145      * @see #setSize
2146      * @since JDK1.1
2147      */
2148     public Dimension getSize() {
2149         return size();
2150     }
2151 
2152     /**





2153      * @deprecated As of JDK version 1.1,
2154      * replaced by <code>getSize()</code>.
2155      */
2156     @Deprecated
2157     public Dimension size() {
2158         return new Dimension(width, height);
2159     }
2160 
2161     /**
2162      * Resizes this component so that it has width <code>width</code>
2163      * and height <code>height</code>.
2164      * <p>
2165      * This method changes layout-related information, and therefore,
2166      * invalidates the component hierarchy.
2167      *
2168      * @param width the new width of this component in pixels
2169      * @param height the new height of this component in pixels
2170      * @see #getSize
2171      * @see #setBounds
2172      * @see #invalidate
2173      * @since JDK1.1
2174      */
2175     public void setSize(int width, int height) {
2176         resize(width, height);
2177     }
2178 
2179     /**




2180      * @deprecated As of JDK version 1.1,
2181      * replaced by <code>setSize(int, int)</code>.
2182      */
2183     @Deprecated
2184     public void resize(int width, int height) {
2185         synchronized(getTreeLock()) {
2186             setBoundsOp(ComponentPeer.SET_SIZE);
2187             setBounds(x, y, width, height);
2188         }
2189     }
2190 
2191     /**
2192      * Resizes this component so that it has width <code>d.width</code>
2193      * and height <code>d.height</code>.
2194      * <p>
2195      * This method changes layout-related information, and therefore,
2196      * invalidates the component hierarchy.
2197      *
2198      * @param d the dimension specifying the new size
2199      *          of this component
2200      * @throws NullPointerException if {@code d} is {@code null}
2201      * @see #setSize
2202      * @see #setBounds
2203      * @see #invalidate
2204      * @since JDK1.1
2205      */
2206     public void setSize(Dimension d) {
2207         resize(d);
2208     }
2209 
2210     /**




2211      * @deprecated As of JDK version 1.1,
2212      * replaced by <code>setSize(Dimension)</code>.
2213      */
2214     @Deprecated
2215     public void resize(Dimension d) {
2216         setSize(d.width, d.height);
2217     }
2218 
2219     /**
2220      * Gets the bounds of this component in the form of a
2221      * <code>Rectangle</code> object. The bounds specify this
2222      * component's width, height, and location relative to
2223      * its parent.
2224      * @return a rectangle indicating this component's bounds
2225      * @see #setBounds
2226      * @see #getLocation
2227      * @see #getSize
2228      */
2229     public Rectangle getBounds() {
2230         return bounds();
2231     }
2232 
2233     /**



2234      * @deprecated As of JDK version 1.1,
2235      * replaced by <code>getBounds()</code>.
2236      */
2237     @Deprecated
2238     public Rectangle bounds() {
2239         return new Rectangle(x, y, width, height);
2240     }
2241 
2242     /**
2243      * Moves and resizes this component. The new location of the top-left
2244      * corner is specified by <code>x</code> and <code>y</code>, and the
2245      * new size is specified by <code>width</code> and <code>height</code>.
2246      * <p>
2247      * This method changes layout-related information, and therefore,
2248      * invalidates the component hierarchy.
2249      *
2250      * @param x the new <i>x</i>-coordinate of this component
2251      * @param y the new <i>y</i>-coordinate of this component
2252      * @param width the new <code>width</code> of this component
2253      * @param height the new <code>height</code> of this
2254      *          component
2255      * @see #getBounds
2256      * @see #setLocation(int, int)
2257      * @see #setLocation(Point)
2258      * @see #setSize(int, int)
2259      * @see #setSize(Dimension)
2260      * @see #invalidate
2261      * @since JDK1.1
2262      */
2263     public void setBounds(int x, int y, int width, int height) {
2264         reshape(x, y, width, height);
2265     }
2266 
2267     /**







2268      * @deprecated As of JDK version 1.1,
2269      * replaced by <code>setBounds(int, int, int, int)</code>.
2270      */
2271     @Deprecated
2272     public void reshape(int x, int y, int width, int height) {
2273         synchronized (getTreeLock()) {
2274             try {
2275                 setBoundsOp(ComponentPeer.SET_BOUNDS);
2276                 boolean resized = (this.width != width) || (this.height != height);
2277                 boolean moved = (this.x != x) || (this.y != y);
2278                 if (!resized && !moved) {
2279                     return;
2280                 }
2281                 int oldX = this.x;
2282                 int oldY = this.y;
2283                 int oldWidth = this.width;
2284                 int oldHeight = this.height;
2285                 this.x = x;
2286                 this.y = y;
2287                 this.width = width;


2614      *         with a non-null value.
2615      * @since 1.5
2616      */
2617     public boolean isPreferredSizeSet() {
2618         return prefSizeSet;
2619     }
2620 
2621 
2622     /**
2623      * Gets the preferred size of this component.
2624      * @return a dimension object indicating this component's preferred size
2625      * @see #getMinimumSize
2626      * @see LayoutManager
2627      */
2628     public Dimension getPreferredSize() {
2629         return preferredSize();
2630     }
2631 
2632 
2633     /**



2634      * @deprecated As of JDK version 1.1,
2635      * replaced by <code>getPreferredSize()</code>.
2636      */
2637     @Deprecated
2638     public Dimension preferredSize() {
2639         /* Avoid grabbing the lock if a reasonable cached size value
2640          * is available.
2641          */
2642         Dimension dim = prefSize;
2643         if (dim == null || !(isPreferredSizeSet() || isValid())) {
2644             synchronized (getTreeLock()) {
2645                 prefSize = (peer != null) ?
2646                     peer.getPreferredSize() :
2647                     getMinimumSize();
2648                 dim = prefSize;
2649             }
2650         }
2651         return new Dimension(dim);
2652     }
2653 


2684      *
2685      * @return true if <code>setMinimumSize</code> has been invoked with a
2686      *              non-null value.
2687      * @since 1.5
2688      */
2689     public boolean isMinimumSizeSet() {
2690         return minSizeSet;
2691     }
2692 
2693     /**
2694      * Gets the minimum size of this component.
2695      * @return a dimension object indicating this component's minimum size
2696      * @see #getPreferredSize
2697      * @see LayoutManager
2698      */
2699     public Dimension getMinimumSize() {
2700         return minimumSize();
2701     }
2702 
2703     /**



2704      * @deprecated As of JDK version 1.1,
2705      * replaced by <code>getMinimumSize()</code>.
2706      */
2707     @Deprecated
2708     public Dimension minimumSize() {
2709         /* Avoid grabbing the lock if a reasonable cached size value
2710          * is available.
2711          */
2712         Dimension dim = minSize;
2713         if (dim == null || !(isMinimumSizeSet() || isValid())) {
2714             synchronized (getTreeLock()) {
2715                 minSize = (peer != null) ?
2716                     peer.getMinimumSize() :
2717                     size();
2718                 dim = minSize;
2719             }
2720         }
2721         return new Dimension(dim);
2722     }
2723 


2764     /**
2765      * Gets the maximum size of this component.
2766      * @return a dimension object indicating this component's maximum size
2767      * @see #getMinimumSize
2768      * @see #getPreferredSize
2769      * @see LayoutManager
2770      */
2771     public Dimension getMaximumSize() {
2772         if (isMaximumSizeSet()) {
2773             return new Dimension(maxSize);
2774         }
2775         return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
2776     }
2777 
2778     /**
2779      * Returns the alignment along the x axis.  This specifies how
2780      * the component would like to be aligned relative to other
2781      * components.  The value should be a number between 0 and 1
2782      * where 0 represents alignment along the origin, 1 is aligned
2783      * the furthest away from the origin, 0.5 is centered, etc.


2784      */
2785     public float getAlignmentX() {
2786         return CENTER_ALIGNMENT;
2787     }
2788 
2789     /**
2790      * Returns the alignment along the y axis.  This specifies how
2791      * the component would like to be aligned relative to other
2792      * components.  The value should be a number between 0 and 1
2793      * where 0 represents alignment along the origin, 1 is aligned
2794      * the furthest away from the origin, 0.5 is centered, etc.


2795      */
2796     public float getAlignmentY() {
2797         return CENTER_ALIGNMENT;
2798     }
2799 
2800     /**
2801      * Returns the baseline.  The baseline is measured from the top of
2802      * the component.  This method is primarily meant for
2803      * <code>LayoutManager</code>s to align components along their
2804      * baseline.  A return value less than 0 indicates this component
2805      * does not have a reasonable baseline and that
2806      * <code>LayoutManager</code>s should not align this component on
2807      * its baseline.
2808      * <p>
2809      * The default implementation returns -1.  Subclasses that support
2810      * baseline should override appropriately.  If a value &gt;= 0 is
2811      * returned, then the component has a valid baseline for any
2812      * size &gt;= the minimum size and <code>getBaselineResizeBehavior</code>
2813      * can be used to determine how the baseline changes with size.
2814      *


3140         if (peer instanceof LightweightPeer) {
3141             Container nativeContainer = getNativeContainer();
3142 
3143             if (nativeContainer == null) return;
3144 
3145             ComponentPeer cPeer = nativeContainer.getPeer();
3146 
3147             if (cPeer != null) {
3148                 cPeer.updateCursorImmediately();
3149             }
3150         } else if (peer != null) {
3151             peer.updateCursorImmediately();
3152         }
3153     }
3154 
3155     /**
3156      * Gets the cursor set in the component. If the component does
3157      * not have a cursor set, the cursor of its parent is returned.
3158      * If no cursor is set in the entire hierarchy,
3159      * <code>Cursor.DEFAULT_CURSOR</code> is returned.


3160      * @see #setCursor
3161      * @since      JDK1.1
3162      */
3163     public Cursor getCursor() {
3164         return getCursor_NoClientCode();
3165     }
3166 
3167     final Cursor getCursor_NoClientCode() {
3168         Cursor cursor = this.cursor;
3169         if (cursor != null) {
3170             return cursor;
3171         }
3172         Container parent = this.parent;
3173         if (parent != null) {
3174             return parent.getCursor_NoClientCode();
3175         } else {
3176             return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
3177         }
3178     }
3179 


4243      * Inner class for blitting offscreen surfaces to a component.
4244      *
4245      * @author Michael Martak
4246      * @since 1.4
4247      */
4248     protected class BltBufferStrategy extends BufferStrategy {
4249 
4250         /**
4251          * The buffering capabilities
4252          */
4253         protected BufferCapabilities caps; // = null
4254         /**
4255          * The back buffers
4256          */
4257         protected VolatileImage[] backBuffers; // = null
4258         /**
4259          * Whether or not the drawing buffer has been recently restored from
4260          * a lost state.
4261          */
4262         protected boolean validatedContents; // = false

4263         /**
4264          * Size of the back buffers
4265          */
4266         protected int width;




4267         protected int height;
4268 
4269         /**
4270          * Insets for the hosting Component.  The size of the back buffer
4271          * is constrained by these.
4272          */
4273         private Insets insets;
4274 
4275         /**
4276          * Creates a new blt buffer strategy around a component
4277          * @param numBuffers number of buffers to create, including the
4278          * front buffer
4279          * @param caps the capabilities of the buffers
4280          */
4281         protected BltBufferStrategy(int numBuffers, BufferCapabilities caps) {
4282             this.caps = caps;
4283             createBackBuffers(numBuffers - 1);
4284         }
4285 
4286         /**
4287          * {@inheritDoc}
4288          * @since 1.6
4289          */
4290         public void dispose() {
4291             if (backBuffers != null) {
4292                 for (int counter = backBuffers.length - 1; counter >= 0;
4293                      counter--) {
4294                     if (backBuffers[counter] != null) {
4295                         backBuffers[counter].flush();
4296                         backBuffers[counter] = null;
4297                     }
4298                 }
4299             }
4300             if (Component.this.bufferStrategy == this) {
4301                 Component.this.bufferStrategy = null;
4302             }
4303         }
4304 
4305         /**
4306          * Creates the back buffers


4307          */
4308         protected void createBackBuffers(int numBuffers) {
4309             if (numBuffers == 0) {
4310                 backBuffers = null;
4311             } else {
4312                 // save the current bounds
4313                 width = getWidth();
4314                 height = getHeight();
4315                 insets = getInsets_NoClientCode();
4316                 int iWidth = width - insets.left - insets.right;
4317                 int iHeight = height - insets.top - insets.bottom;
4318 
4319                 // It is possible for the component's width and/or height
4320                 // to be 0 here.  Force the size of the backbuffers to
4321                 // be > 0 so that creating the image won't fail.
4322                 iWidth = Math.max(1, iWidth);
4323                 iHeight = Math.max(1, iHeight);
4324                 if (backBuffers == null) {
4325                     backBuffers = new VolatileImage[numBuffers];
4326                 } else {


4576             return false;
4577         }
4578         public boolean contentsRestored() {
4579             return false;
4580         }
4581         public void show() {
4582             // Do nothing
4583         }
4584     } // Inner class SingleBufferStrategy
4585 
4586     /**
4587      * Sets whether or not paint messages received from the operating system
4588      * should be ignored.  This does not affect paint events generated in
4589      * software by the AWT, unless they are an immediate response to an
4590      * OS-level paint message.
4591      * <p>
4592      * This is useful, for example, if running under full-screen mode and
4593      * better performance is desired, or if page-flipping is used as the
4594      * buffer strategy.
4595      *



4596      * @since 1.4
4597      * @see #getIgnoreRepaint
4598      * @see Canvas#createBufferStrategy
4599      * @see Window#createBufferStrategy
4600      * @see java.awt.image.BufferStrategy
4601      * @see GraphicsDevice#setFullScreenWindow
4602      */
4603     public void setIgnoreRepaint(boolean ignoreRepaint) {
4604         this.ignoreRepaint = ignoreRepaint;
4605     }
4606 
4607     /**
4608      * @return whether or not paint messages received from the operating system
4609      * should be ignored.
4610      *
4611      * @since 1.4
4612      * @see #setIgnoreRepaint
4613      */
4614     public boolean getIgnoreRepaint() {
4615         return ignoreRepaint;
4616     }
4617 
4618     /**
4619      * Checks whether this component "contains" the specified point,
4620      * where <code>x</code> and <code>y</code> are defined to be
4621      * relative to the coordinate system of this component.

4622      * @param     x   the <i>x</i> coordinate of the point
4623      * @param     y   the <i>y</i> coordinate of the point


4624      * @see       #getComponentAt(int, int)
4625      * @since     JDK1.1
4626      */
4627     public boolean contains(int x, int y) {
4628         return inside(x, y);
4629     }
4630 
4631     /**






4632      * @deprecated As of JDK version 1.1,
4633      * replaced by contains(int, int).
4634      */
4635     @Deprecated
4636     public boolean inside(int x, int y) {
4637         return (x >= 0) && (x < width) && (y >= 0) && (y < height);
4638     }
4639 
4640     /**
4641      * Checks whether this component "contains" the specified point,
4642      * where the point's <i>x</i> and <i>y</i> coordinates are defined
4643      * to be relative to the coordinate system of this component.

4644      * @param     p     the point


4645      * @throws    NullPointerException if {@code p} is {@code null}
4646      * @see       #getComponentAt(Point)
4647      * @since     JDK1.1
4648      */
4649     public boolean contains(Point p) {
4650         return contains(p.x, p.y);
4651     }
4652 
4653     /**
4654      * Determines if this component or one of its immediate
4655      * subcomponents contains the (<i>x</i>,&nbsp;<i>y</i>) location,
4656      * and if so, returns the containing component. This method only
4657      * looks one level deep. If the point (<i>x</i>,&nbsp;<i>y</i>) is
4658      * inside a subcomponent that itself has subcomponents, it does not
4659      * go looking down the subcomponent tree.
4660      * <p>
4661      * The <code>locate</code> method of <code>Component</code> simply
4662      * returns the component itself if the (<i>x</i>,&nbsp;<i>y</i>)
4663      * coordinate location is inside its bounding box, and <code>null</code>
4664      * otherwise.
4665      * @param     x   the <i>x</i> coordinate
4666      * @param     y   the <i>y</i> coordinate
4667      * @return    the component or subcomponent that contains the
4668      *                (<i>x</i>,&nbsp;<i>y</i>) location;
4669      *                <code>null</code> if the location
4670      *                is outside this component
4671      * @see       #contains(int, int)
4672      * @since     JDK1.0
4673      */
4674     public Component getComponentAt(int x, int y) {
4675         return locate(x, y);
4676     }
4677 
4678     /**







4679      * @deprecated As of JDK version 1.1,
4680      * replaced by getComponentAt(int, int).
4681      */
4682     @Deprecated
4683     public Component locate(int x, int y) {
4684         return contains(x, y) ? this : null;
4685     }
4686 
4687     /**
4688      * Returns the component or subcomponent that contains the
4689      * specified point.
4690      * @param     p   the point

4691      * @see       java.awt.Component#contains
4692      * @since     JDK1.1
4693      */
4694     public Component getComponentAt(Point p) {
4695         return getComponentAt(p.x, p.y);
4696     }
4697 
4698     /**

4699      * @deprecated As of JDK version 1.1,
4700      * replaced by <code>dispatchEvent(AWTEvent e)</code>.
4701      */
4702     @Deprecated
4703     public void deliverEvent(Event e) {
4704         postEvent(e);
4705     }
4706 
4707     /**
4708      * Dispatches an event to this component or one of its sub components.
4709      * Calls <code>processEvent</code> before returning for 1.1-style
4710      * events which have been enabled for the <code>Component</code>.
4711      * @param e the event
4712      */
4713     public final void dispatchEvent(AWTEvent e) {
4714         dispatchEventImpl(e);
4715     }
4716 
4717     @SuppressWarnings("deprecation")
4718     void dispatchEventImpl(AWTEvent e) {


6729      * @see         #addHierarchyBoundsListener
6730      * @see         #enableEvents
6731      * @since       1.3
6732      */
6733     protected void processHierarchyBoundsEvent(HierarchyEvent e) {
6734         HierarchyBoundsListener listener = hierarchyBoundsListener;
6735         if (listener != null) {
6736             int id = e.getID();
6737             switch (id) {
6738               case HierarchyEvent.ANCESTOR_MOVED:
6739                   listener.ancestorMoved(e);
6740                   break;
6741               case HierarchyEvent.ANCESTOR_RESIZED:
6742                   listener.ancestorResized(e);
6743                   break;
6744             }
6745         }
6746     }
6747 
6748     /**


6749      * @deprecated As of JDK version 1.1
6750      * replaced by processEvent(AWTEvent).
6751      */
6752     @Deprecated
6753     public boolean handleEvent(Event evt) {
6754         switch (evt.id) {
6755           case Event.MOUSE_ENTER:
6756               return mouseEnter(evt, evt.x, evt.y);
6757 
6758           case Event.MOUSE_EXIT:
6759               return mouseExit(evt, evt.x, evt.y);
6760 
6761           case Event.MOUSE_MOVE:
6762               return mouseMove(evt, evt.x, evt.y);
6763 
6764           case Event.MOUSE_DOWN:
6765               return mouseDown(evt, evt.x, evt.y);
6766 
6767           case Event.MOUSE_DRAG:
6768               return mouseDrag(evt, evt.x, evt.y);


6772 
6773           case Event.KEY_PRESS:
6774           case Event.KEY_ACTION:
6775               return keyDown(evt, evt.key);
6776 
6777           case Event.KEY_RELEASE:
6778           case Event.KEY_ACTION_RELEASE:
6779               return keyUp(evt, evt.key);
6780 
6781           case Event.ACTION_EVENT:
6782               return action(evt, evt.arg);
6783           case Event.GOT_FOCUS:
6784               return gotFocus(evt, evt.arg);
6785           case Event.LOST_FOCUS:
6786               return lostFocus(evt, evt.arg);
6787         }
6788         return false;
6789     }
6790 
6791     /**




6792      * @deprecated As of JDK version 1.1,
6793      * replaced by processMouseEvent(MouseEvent).
6794      */
6795     @Deprecated
6796     public boolean mouseDown(Event evt, int x, int y) {
6797         return false;
6798     }
6799 
6800     /**




6801      * @deprecated As of JDK version 1.1,
6802      * replaced by processMouseMotionEvent(MouseEvent).
6803      */
6804     @Deprecated
6805     public boolean mouseDrag(Event evt, int x, int y) {
6806         return false;
6807     }
6808 
6809     /**




6810      * @deprecated As of JDK version 1.1,
6811      * replaced by processMouseEvent(MouseEvent).
6812      */
6813     @Deprecated
6814     public boolean mouseUp(Event evt, int x, int y) {
6815         return false;
6816     }
6817 
6818     /**




6819      * @deprecated As of JDK version 1.1,
6820      * replaced by processMouseMotionEvent(MouseEvent).
6821      */
6822     @Deprecated
6823     public boolean mouseMove(Event evt, int x, int y) {
6824         return false;
6825     }
6826 
6827     /**




6828      * @deprecated As of JDK version 1.1,
6829      * replaced by processMouseEvent(MouseEvent).
6830      */
6831     @Deprecated
6832     public boolean mouseEnter(Event evt, int x, int y) {
6833         return false;
6834     }
6835 
6836     /**




6837      * @deprecated As of JDK version 1.1,
6838      * replaced by processMouseEvent(MouseEvent).
6839      */
6840     @Deprecated
6841     public boolean mouseExit(Event evt, int x, int y) {
6842         return false;
6843     }
6844 
6845     /**



6846      * @deprecated As of JDK version 1.1,
6847      * replaced by processKeyEvent(KeyEvent).
6848      */
6849     @Deprecated
6850     public boolean keyDown(Event evt, int key) {
6851         return false;
6852     }
6853 
6854     /**



6855      * @deprecated As of JDK version 1.1,
6856      * replaced by processKeyEvent(KeyEvent).
6857      */
6858     @Deprecated
6859     public boolean keyUp(Event evt, int key) {
6860         return false;
6861     }
6862 
6863     /**



6864      * @deprecated As of JDK version 1.1,
6865      * should register this component as ActionListener on component
6866      * which fires action events.
6867      */
6868     @Deprecated
6869     public boolean action(Event evt, Object what) {
6870         return false;
6871     }
6872 
6873     /**
6874      * Makes this <code>Component</code> displayable by connecting it to a
6875      * native screen resource.
6876      * This method is called internally by the toolkit and should
6877      * not be called directly by programs.
6878      * <p>
6879      * This method changes layout-related information, and therefore,
6880      * invalidates the component hierarchy.
6881      *
6882      * @see       #isDisplayable
6883      * @see       #removeNotify


7053                 // (or has no shape at all).
7054                 this.compoundShape = null;
7055             }
7056 
7057             if (hierarchyListener != null ||
7058                 (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 ||
7059                 Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK)) {
7060                 HierarchyEvent e =
7061                     new HierarchyEvent(this, HierarchyEvent.HIERARCHY_CHANGED,
7062                                        this, parent,
7063                                        HierarchyEvent.DISPLAYABILITY_CHANGED |
7064                                        ((isRecursivelyVisible())
7065                                         ? HierarchyEvent.SHOWING_CHANGED
7066                                         : 0));
7067                 dispatchEvent(e);
7068             }
7069         }
7070     }
7071 
7072     /**



7073      * @deprecated As of JDK version 1.1,
7074      * replaced by processFocusEvent(FocusEvent).
7075      */
7076     @Deprecated
7077     public boolean gotFocus(Event evt, Object what) {
7078         return false;
7079     }
7080 
7081     /**



7082      * @deprecated As of JDK version 1.1,
7083      * replaced by processFocusEvent(FocusEvent).
7084      */
7085     @Deprecated
7086     public boolean lostFocus(Event evt, Object what) {
7087         return false;
7088     }
7089 
7090     /**
7091      * Returns whether this <code>Component</code> can become the focus
7092      * owner.
7093      *
7094      * @return <code>true</code> if this <code>Component</code> is
7095      * focusable; <code>false</code> otherwise
7096      * @see #setFocusable
7097      * @since JDK1.1
7098      * @deprecated As of 1.4, replaced by <code>isFocusable()</code>.
7099      */
7100     @Deprecated
7101     public boolean isFocusTraversable() {


8373      *
8374      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
8375      * @see #getPropertyChangeListeners(java.lang.String)
8376      * @see #removePropertyChangeListener(java.beans.PropertyChangeListener)
8377      */
8378     public void removePropertyChangeListener(
8379                                                           String propertyName,
8380                                                           PropertyChangeListener listener) {
8381         synchronized (getObjectLock()) {
8382             if (listener == null || changeSupport == null) {
8383                 return;
8384             }
8385             changeSupport.removePropertyChangeListener(propertyName, listener);
8386         }
8387     }
8388 
8389     /**
8390      * Returns an array of all the listeners which have been associated
8391      * with the named property.
8392      *


8393      * @return all of the <code>PropertyChangeListener</code>s associated with
8394      *         the named property; if no such listeners have been added or
8395      *         if <code>propertyName</code> is <code>null</code>, an empty
8396      *         array is returned
8397      *
8398      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
8399      * @see #removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
8400      * @see #getPropertyChangeListeners
8401      * @since 1.4
8402      */
8403     public PropertyChangeListener[] getPropertyChangeListeners(
8404                                                                             String propertyName) {
8405         synchronized (getObjectLock()) {
8406             if (changeSupport == null) {
8407                 return new PropertyChangeListener[0];
8408             }
8409             return changeSupport.getPropertyChangeListeners(propertyName);
8410         }
8411     }
8412 
8413     /**
8414      * Support for reporting bound property changes for Object properties.
8415      * This method can be called when a bound property has changed and it will
8416      * send the appropriate PropertyChangeEvent to any registered
8417      * PropertyChangeListeners.
8418      *
8419      * @param propertyName the property whose value has changed
8420      * @param oldValue the property's previous value
8421      * @param newValue the property's new value
8422      */
8423     protected void firePropertyChange(String propertyName,
8424                                       Object oldValue, Object newValue) {


8862      * Sets the language-sensitive orientation that is to be used to order
8863      * the elements or text within this component.  Language-sensitive
8864      * <code>LayoutManager</code> and <code>Component</code>
8865      * subclasses will use this property to
8866      * determine how to lay out and draw components.
8867      * <p>
8868      * At construction time, a component's orientation is set to
8869      * <code>ComponentOrientation.UNKNOWN</code>,
8870      * indicating that it has not been specified
8871      * explicitly.  The UNKNOWN orientation behaves the same as
8872      * <code>ComponentOrientation.LEFT_TO_RIGHT</code>.
8873      * <p>
8874      * To set the orientation of a single component, use this method.
8875      * To set the orientation of an entire component
8876      * hierarchy, use
8877      * {@link #applyComponentOrientation applyComponentOrientation}.
8878      * <p>
8879      * This method changes layout-related information, and therefore,
8880      * invalidates the component hierarchy.
8881      *

8882      *
8883      * @see ComponentOrientation
8884      * @see #invalidate
8885      *
8886      * @author Laura Werner, IBM
8887      * @beaninfo
8888      *       bound: true
8889      */
8890     public void setComponentOrientation(ComponentOrientation o) {
8891         ComponentOrientation oldValue = componentOrientation;
8892         componentOrientation = o;
8893 
8894         // This is a bound property, so report the change to
8895         // any registered listeners.  (Cheap if there are none.)
8896         firePropertyChange("componentOrientation", oldValue, o);
8897 
8898         // This could change the preferred size of the Component.
8899         invalidateIfValid();
8900     }
8901 
8902     /**
8903      * Retrieves the language-sensitive orientation that is to be used to order
8904      * the elements or text within this component.  <code>LayoutManager</code>
8905      * and <code>Component</code>
8906      * subclasses that wish to respect orientation should call this method to
8907      * get the component's orientation before performing layout or drawing.
8908      *

8909      * @see ComponentOrientation
8910      *
8911      * @author Laura Werner, IBM
8912      */
8913     public ComponentOrientation getComponentOrientation() {
8914         return componentOrientation;
8915     }
8916 
8917     /**
8918      * Sets the <code>ComponentOrientation</code> property of this component
8919      * and all components contained within it.
8920      * <p>
8921      * This method changes layout-related information, and therefore,
8922      * invalidates the component hierarchy.
8923      *
8924      *
8925      * @param orientation the new component orientation of this component and
8926      *        the components contained within it.
8927      * @exception NullPointerException if <code>orientation</code> is null.
8928      * @see #setComponentOrientation


9046      */
9047     protected abstract class AccessibleAWTComponent extends AccessibleContext
9048         implements Serializable, AccessibleComponent {
9049 
9050         private static final long serialVersionUID = 642321655757800191L;
9051 
9052         /**
9053          * Though the class is abstract, this should be called by
9054          * all sub-classes.
9055          */
9056         protected AccessibleAWTComponent() {
9057         }
9058 
9059         /**
9060          * Number of PropertyChangeListener objects registered. It's used
9061          * to add/remove ComponentListener and FocusListener to track
9062          * target Component's state.
9063          */
9064         private volatile transient int propertyListenersCount = 0;
9065 




9066         protected ComponentListener accessibleAWTComponentHandler = null;





9067         protected FocusListener accessibleAWTFocusHandler = null;
9068 
9069         /**
9070          * Fire PropertyChange listener, if one is registered,
9071          * when shown/hidden..
9072          * @since 1.3
9073          */
9074         protected class AccessibleAWTComponentHandler implements ComponentListener {
9075             public void componentHidden(ComponentEvent e)  {
9076                 if (accessibleContext != null) {
9077                     accessibleContext.firePropertyChange(
9078                                                          AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
9079                                                          AccessibleState.VISIBLE, null);
9080                 }
9081             }
9082 
9083             public void componentShown(ComponentEvent e)  {
9084                 if (accessibleContext != null) {
9085                     accessibleContext.firePropertyChange(
9086                                                          AccessibleContext.ACCESSIBLE_STATE_PROPERTY,




1058 
1059     // NOTE: This method may be called by privileged threads.
1060     //       This functionality is implemented in a package-private method
1061     //       to insure that it cannot be overridden by client subclasses.
1062     //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
1063     final Container getParent_NoClientCode() {
1064         return parent;
1065     }
1066 
1067     // This method is overridden in the Window class to return null,
1068     //    because the parent field of the Window object contains
1069     //    the owner of the window, not its parent.
1070     Container getContainer() {
1071         return getParent_NoClientCode();
1072     }
1073 
1074     /**
1075      * @deprecated As of JDK version 1.1,
1076      * programs should not directly manipulate peers;
1077      * replaced by <code>boolean isDisplayable()</code>.
1078      * @return the peer for this component
1079      */
1080     @Deprecated
1081     public ComponentPeer getPeer() {
1082         return peer;
1083     }
1084 
1085     /**
1086      * Associate a <code>DropTarget</code> with this component.
1087      * The <code>Component</code> will receive drops only if it
1088      * is enabled.
1089      *
1090      * @see #isEnabled
1091      * @param dt The DropTarget
1092      */
1093 
1094     public synchronized void setDropTarget(DropTarget dt) {
1095         if (dt == dropTarget || (dropTarget != null && dropTarget.equals(dt)))
1096             return;
1097 
1098         DropTarget old;


1116         if ((dropTarget = dt) != null) {
1117             try {
1118                 dropTarget.setComponent(this);
1119                 if (peer != null) dropTarget.addNotify(peer);
1120             } catch (IllegalArgumentException iae) {
1121                 if (old != null) {
1122                     try {
1123                         old.setComponent(this);
1124                         if (peer != null) dropTarget.addNotify(peer);
1125                     } catch (IllegalArgumentException iae1) {
1126                         // ignore it!
1127                     }
1128                 }
1129             }
1130         }
1131     }
1132 
1133     /**
1134      * Gets the <code>DropTarget</code> associated with this
1135      * <code>Component</code>.
1136      *
1137      * @return the drop target
1138      */
1139 
1140     public synchronized DropTarget getDropTarget() { return dropTarget; }
1141 
1142     /**
1143      * Gets the <code>GraphicsConfiguration</code> associated with this
1144      * <code>Component</code>.
1145      * If the <code>Component</code> has not been assigned a specific
1146      * <code>GraphicsConfiguration</code>,
1147      * the <code>GraphicsConfiguration</code> of the
1148      * <code>Component</code> object's top-level container is
1149      * returned.
1150      * If the <code>Component</code> has been created, but not yet added
1151      * to a <code>Container</code>, this method returns <code>null</code>.
1152      *
1153      * @return the <code>GraphicsConfiguration</code> used by this
1154      *          <code>Component</code> or <code>null</code>
1155      * @since 1.3
1156      */
1157     public GraphicsConfiguration getGraphicsConfiguration() {


1484         if (!enabled) {
1485             synchronized (getTreeLock()) {
1486                 enabled = true;
1487                 ComponentPeer peer = this.peer;
1488                 if (peer != null) {
1489                     peer.setEnabled(true);
1490                     if (visible) {
1491                         updateCursorImmediately();
1492                     }
1493                 }
1494             }
1495             if (accessibleContext != null) {
1496                 accessibleContext.firePropertyChange(
1497                                                      AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
1498                                                      null, AccessibleState.ENABLED);
1499             }
1500         }
1501     }
1502 
1503     /**
1504      * Enables or disables this component.
1505      *
1506      * @param  b {@code true} to enable this component;
1507      *         otherwise {@code false}
1508      *
1509      * @deprecated As of JDK version 1.1,
1510      * replaced by <code>setEnabled(boolean)</code>.
1511      */
1512     @Deprecated
1513     public void enable(boolean b) {
1514         if (b) {
1515             enable();
1516         } else {
1517             disable();
1518         }
1519     }
1520 
1521     /**
1522      * @deprecated As of JDK version 1.1,
1523      * replaced by <code>setEnabled(boolean)</code>.
1524      */
1525     @Deprecated
1526     public void disable() {
1527         if (enabled) {
1528             KeyboardFocusManager.clearMostRecentFocusOwner(this);


1647                     }
1648                     updateCursorImmediately();
1649                 }
1650 
1651                 if (componentListener != null ||
1652                     (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ||
1653                     Toolkit.enabledOnToolkit(AWTEvent.COMPONENT_EVENT_MASK)) {
1654                     ComponentEvent e = new ComponentEvent(this,
1655                                                           ComponentEvent.COMPONENT_SHOWN);
1656                     Toolkit.getEventQueue().postEvent(e);
1657                 }
1658             }
1659             Container parent = this.parent;
1660             if (parent != null) {
1661                 parent.invalidate();
1662             }
1663         }
1664     }
1665 
1666     /**
1667      * Makes this component visible or invisible.
1668      *
1669      * @param  b {@code true} to make this component visible;
1670      *         otherwise {@code false}
1671      *
1672      * @deprecated As of JDK version 1.1,
1673      * replaced by <code>setVisible(boolean)</code>.
1674      */
1675     @Deprecated
1676     public void show(boolean b) {
1677         if (b) {
1678             show();
1679         } else {
1680             hide();
1681         }
1682     }
1683 
1684     boolean containsFocus() {
1685         return isFocusOwner();
1686     }
1687 
1688     void clearMostRecentFocusOwnerOnHide() {
1689         KeyboardFocusManager.clearMostRecentFocusOwner(this);
1690     }
1691 


2064                 // lightweight component location needs to be translated
2065                 // relative to a native component.
2066                 Container host = getNativeContainer();
2067                 Point pt = host.peer.getLocationOnScreen();
2068                 for(Component c = this; c != host; c = c.getParent()) {
2069                     pt.x += c.x;
2070                     pt.y += c.y;
2071                 }
2072                 return pt;
2073             } else {
2074                 Point pt = peer.getLocationOnScreen();
2075                 return pt;
2076             }
2077         } else {
2078             throw new IllegalComponentStateException("component must be showing on the screen to determine its location");
2079         }
2080     }
2081 
2082 
2083     /**
2084      * Returns the location of this component's top left corner.
2085      *
2086      * @return the location of this component's top left corner
2087      * @deprecated As of JDK version 1.1,
2088      * replaced by <code>getLocation()</code>.
2089      */
2090     @Deprecated
2091     public Point location() {
2092         return location_NoClientCode();
2093     }
2094 
2095     private Point location_NoClientCode() {
2096         return new Point(x, y);
2097     }
2098 
2099     /**
2100      * Moves this component to a new location. The top-left corner of
2101      * the new location is specified by the <code>x</code> and <code>y</code>
2102      * parameters in the coordinate space of this component's parent.
2103      * <p>
2104      * This method changes layout-related information, and therefore,
2105      * invalidates the component hierarchy.
2106      *
2107      * @param x the <i>x</i>-coordinate of the new location's
2108      *          top-left corner in the parent's coordinate space
2109      * @param y the <i>y</i>-coordinate of the new location's
2110      *          top-left corner in the parent's coordinate space
2111      * @see #getLocation
2112      * @see #setBounds
2113      * @see #invalidate
2114      * @since JDK1.1
2115      */
2116     public void setLocation(int x, int y) {
2117         move(x, y);
2118     }
2119 
2120     /**
2121      * Moves this component to a new location.
2122      *
2123      * @param  x the <i>x</i>-coordinate of the new location's
2124      *           top-left corner in the parent's coordinate space
2125      * @param  y the <i>y</i>-coordinate of the new location's
2126      *           top-left corner in the parent's coordinate space
2127      *
2128      * @deprecated As of JDK version 1.1,
2129      * replaced by <code>setLocation(int, int)</code>.
2130      */
2131     @Deprecated
2132     public void move(int x, int y) {
2133         synchronized(getTreeLock()) {
2134             setBoundsOp(ComponentPeer.SET_LOCATION);
2135             setBounds(x, y, width, height);
2136         }
2137     }
2138 
2139     /**
2140      * Moves this component to a new location. The top-left corner of
2141      * the new location is specified by point <code>p</code>. Point
2142      * <code>p</code> is given in the parent's coordinate space.
2143      * <p>
2144      * This method changes layout-related information, and therefore,
2145      * invalidates the component hierarchy.
2146      *
2147      * @param p the point defining the top-left corner


2156         setLocation(p.x, p.y);
2157     }
2158 
2159     /**
2160      * Returns the size of this component in the form of a
2161      * <code>Dimension</code> object. The <code>height</code>
2162      * field of the <code>Dimension</code> object contains
2163      * this component's height, and the <code>width</code>
2164      * field of the <code>Dimension</code> object contains
2165      * this component's width.
2166      * @return a <code>Dimension</code> object that indicates the
2167      *          size of this component
2168      * @see #setSize
2169      * @since JDK1.1
2170      */
2171     public Dimension getSize() {
2172         return size();
2173     }
2174 
2175     /**
2176      * Returns the size of this component in the form of a
2177      * {@code Dimension} object.
2178      *
2179      * @return the {@code Dimension} object that indicates the
2180      *         size of this component
2181      * @deprecated As of JDK version 1.1,
2182      * replaced by <code>getSize()</code>.
2183      */
2184     @Deprecated
2185     public Dimension size() {
2186         return new Dimension(width, height);
2187     }
2188 
2189     /**
2190      * Resizes this component so that it has width <code>width</code>
2191      * and height <code>height</code>.
2192      * <p>
2193      * This method changes layout-related information, and therefore,
2194      * invalidates the component hierarchy.
2195      *
2196      * @param width the new width of this component in pixels
2197      * @param height the new height of this component in pixels
2198      * @see #getSize
2199      * @see #setBounds
2200      * @see #invalidate
2201      * @since JDK1.1
2202      */
2203     public void setSize(int width, int height) {
2204         resize(width, height);
2205     }
2206 
2207     /**
2208      * Resizes this component.
2209      *
2210      * @param  width the new width of the component
2211      * @param  height the new height of the component
2212      * @deprecated As of JDK version 1.1,
2213      * replaced by <code>setSize(int, int)</code>.
2214      */
2215     @Deprecated
2216     public void resize(int width, int height) {
2217         synchronized(getTreeLock()) {
2218             setBoundsOp(ComponentPeer.SET_SIZE);
2219             setBounds(x, y, width, height);
2220         }
2221     }
2222 
2223     /**
2224      * Resizes this component so that it has width <code>d.width</code>
2225      * and height <code>d.height</code>.
2226      * <p>
2227      * This method changes layout-related information, and therefore,
2228      * invalidates the component hierarchy.
2229      *
2230      * @param d the dimension specifying the new size
2231      *          of this component
2232      * @throws NullPointerException if {@code d} is {@code null}
2233      * @see #setSize
2234      * @see #setBounds
2235      * @see #invalidate
2236      * @since JDK1.1
2237      */
2238     public void setSize(Dimension d) {
2239         resize(d);
2240     }
2241 
2242     /**
2243      * Resizes this component so that it has width {@code d.width}
2244      * and height {@code d.height}.
2245      *
2246      * @param  d the new size of this component
2247      * @deprecated As of JDK version 1.1,
2248      * replaced by <code>setSize(Dimension)</code>.
2249      */
2250     @Deprecated
2251     public void resize(Dimension d) {
2252         setSize(d.width, d.height);
2253     }
2254 
2255     /**
2256      * Gets the bounds of this component in the form of a
2257      * <code>Rectangle</code> object. The bounds specify this
2258      * component's width, height, and location relative to
2259      * its parent.
2260      * @return a rectangle indicating this component's bounds
2261      * @see #setBounds
2262      * @see #getLocation
2263      * @see #getSize
2264      */
2265     public Rectangle getBounds() {
2266         return bounds();
2267     }
2268 
2269     /**
2270      * Returns the bounding rectangle of this component.
2271      *
2272      * @return the bounding rectangle for this component
2273      * @deprecated As of JDK version 1.1,
2274      * replaced by <code>getBounds()</code>.
2275      */
2276     @Deprecated
2277     public Rectangle bounds() {
2278         return new Rectangle(x, y, width, height);
2279     }
2280 
2281     /**
2282      * Moves and resizes this component. The new location of the top-left
2283      * corner is specified by <code>x</code> and <code>y</code>, and the
2284      * new size is specified by <code>width</code> and <code>height</code>.
2285      * <p>
2286      * This method changes layout-related information, and therefore,
2287      * invalidates the component hierarchy.
2288      *
2289      * @param x the new <i>x</i>-coordinate of this component
2290      * @param y the new <i>y</i>-coordinate of this component
2291      * @param width the new <code>width</code> of this component
2292      * @param height the new <code>height</code> of this
2293      *          component
2294      * @see #getBounds
2295      * @see #setLocation(int, int)
2296      * @see #setLocation(Point)
2297      * @see #setSize(int, int)
2298      * @see #setSize(Dimension)
2299      * @see #invalidate
2300      * @since JDK1.1
2301      */
2302     public void setBounds(int x, int y, int width, int height) {
2303         reshape(x, y, width, height);
2304     }
2305 
2306     /**
2307      * Reshapes the bounding rectangle for this component.
2308      *
2309      * @param  x the <i>x</i> coordinate of the upper left corner of the rectangle
2310      * @param  y the <i>y</i> coordinate of the upper left corner of the rectangle
2311      * @param  width the width of the rectangle
2312      * @param  height the height of the rectangle
2313      *
2314      * @deprecated As of JDK version 1.1,
2315      * replaced by <code>setBounds(int, int, int, int)</code>.
2316      */
2317     @Deprecated
2318     public void reshape(int x, int y, int width, int height) {
2319         synchronized (getTreeLock()) {
2320             try {
2321                 setBoundsOp(ComponentPeer.SET_BOUNDS);
2322                 boolean resized = (this.width != width) || (this.height != height);
2323                 boolean moved = (this.x != x) || (this.y != y);
2324                 if (!resized && !moved) {
2325                     return;
2326                 }
2327                 int oldX = this.x;
2328                 int oldY = this.y;
2329                 int oldWidth = this.width;
2330                 int oldHeight = this.height;
2331                 this.x = x;
2332                 this.y = y;
2333                 this.width = width;


2660      *         with a non-null value.
2661      * @since 1.5
2662      */
2663     public boolean isPreferredSizeSet() {
2664         return prefSizeSet;
2665     }
2666 
2667 
2668     /**
2669      * Gets the preferred size of this component.
2670      * @return a dimension object indicating this component's preferred size
2671      * @see #getMinimumSize
2672      * @see LayoutManager
2673      */
2674     public Dimension getPreferredSize() {
2675         return preferredSize();
2676     }
2677 
2678 
2679     /**
2680      * Returns the component's preferred size.
2681      *
2682      * @return the component's preferred size
2683      * @deprecated As of JDK version 1.1,
2684      * replaced by <code>getPreferredSize()</code>.
2685      */
2686     @Deprecated
2687     public Dimension preferredSize() {
2688         /* Avoid grabbing the lock if a reasonable cached size value
2689          * is available.
2690          */
2691         Dimension dim = prefSize;
2692         if (dim == null || !(isPreferredSizeSet() || isValid())) {
2693             synchronized (getTreeLock()) {
2694                 prefSize = (peer != null) ?
2695                     peer.getPreferredSize() :
2696                     getMinimumSize();
2697                 dim = prefSize;
2698             }
2699         }
2700         return new Dimension(dim);
2701     }
2702 


2733      *
2734      * @return true if <code>setMinimumSize</code> has been invoked with a
2735      *              non-null value.
2736      * @since 1.5
2737      */
2738     public boolean isMinimumSizeSet() {
2739         return minSizeSet;
2740     }
2741 
2742     /**
2743      * Gets the minimum size of this component.
2744      * @return a dimension object indicating this component's minimum size
2745      * @see #getPreferredSize
2746      * @see LayoutManager
2747      */
2748     public Dimension getMinimumSize() {
2749         return minimumSize();
2750     }
2751 
2752     /**
2753      * Returns the minimum size of this component.
2754      *
2755      * @return the minimum size of this component
2756      * @deprecated As of JDK version 1.1,
2757      * replaced by <code>getMinimumSize()</code>.
2758      */
2759     @Deprecated
2760     public Dimension minimumSize() {
2761         /* Avoid grabbing the lock if a reasonable cached size value
2762          * is available.
2763          */
2764         Dimension dim = minSize;
2765         if (dim == null || !(isMinimumSizeSet() || isValid())) {
2766             synchronized (getTreeLock()) {
2767                 minSize = (peer != null) ?
2768                     peer.getMinimumSize() :
2769                     size();
2770                 dim = minSize;
2771             }
2772         }
2773         return new Dimension(dim);
2774     }
2775 


2816     /**
2817      * Gets the maximum size of this component.
2818      * @return a dimension object indicating this component's maximum size
2819      * @see #getMinimumSize
2820      * @see #getPreferredSize
2821      * @see LayoutManager
2822      */
2823     public Dimension getMaximumSize() {
2824         if (isMaximumSizeSet()) {
2825             return new Dimension(maxSize);
2826         }
2827         return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
2828     }
2829 
2830     /**
2831      * Returns the alignment along the x axis.  This specifies how
2832      * the component would like to be aligned relative to other
2833      * components.  The value should be a number between 0 and 1
2834      * where 0 represents alignment along the origin, 1 is aligned
2835      * the furthest away from the origin, 0.5 is centered, etc.
2836      *
2837      * @return the horizontal alignment of this component
2838      */
2839     public float getAlignmentX() {
2840         return CENTER_ALIGNMENT;
2841     }
2842 
2843     /**
2844      * Returns the alignment along the y axis.  This specifies how
2845      * the component would like to be aligned relative to other
2846      * components.  The value should be a number between 0 and 1
2847      * where 0 represents alignment along the origin, 1 is aligned
2848      * the furthest away from the origin, 0.5 is centered, etc.
2849      *
2850      * @return the vertical alignment of this component
2851      */
2852     public float getAlignmentY() {
2853         return CENTER_ALIGNMENT;
2854     }
2855 
2856     /**
2857      * Returns the baseline.  The baseline is measured from the top of
2858      * the component.  This method is primarily meant for
2859      * <code>LayoutManager</code>s to align components along their
2860      * baseline.  A return value less than 0 indicates this component
2861      * does not have a reasonable baseline and that
2862      * <code>LayoutManager</code>s should not align this component on
2863      * its baseline.
2864      * <p>
2865      * The default implementation returns -1.  Subclasses that support
2866      * baseline should override appropriately.  If a value &gt;= 0 is
2867      * returned, then the component has a valid baseline for any
2868      * size &gt;= the minimum size and <code>getBaselineResizeBehavior</code>
2869      * can be used to determine how the baseline changes with size.
2870      *


3196         if (peer instanceof LightweightPeer) {
3197             Container nativeContainer = getNativeContainer();
3198 
3199             if (nativeContainer == null) return;
3200 
3201             ComponentPeer cPeer = nativeContainer.getPeer();
3202 
3203             if (cPeer != null) {
3204                 cPeer.updateCursorImmediately();
3205             }
3206         } else if (peer != null) {
3207             peer.updateCursorImmediately();
3208         }
3209     }
3210 
3211     /**
3212      * Gets the cursor set in the component. If the component does
3213      * not have a cursor set, the cursor of its parent is returned.
3214      * If no cursor is set in the entire hierarchy,
3215      * <code>Cursor.DEFAULT_CURSOR</code> is returned.
3216      *
3217      * @return the cursor for this component
3218      * @see #setCursor
3219      * @since      JDK1.1
3220      */
3221     public Cursor getCursor() {
3222         return getCursor_NoClientCode();
3223     }
3224 
3225     final Cursor getCursor_NoClientCode() {
3226         Cursor cursor = this.cursor;
3227         if (cursor != null) {
3228             return cursor;
3229         }
3230         Container parent = this.parent;
3231         if (parent != null) {
3232             return parent.getCursor_NoClientCode();
3233         } else {
3234             return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
3235         }
3236     }
3237 


4301      * Inner class for blitting offscreen surfaces to a component.
4302      *
4303      * @author Michael Martak
4304      * @since 1.4
4305      */
4306     protected class BltBufferStrategy extends BufferStrategy {
4307 
4308         /**
4309          * The buffering capabilities
4310          */
4311         protected BufferCapabilities caps; // = null
4312         /**
4313          * The back buffers
4314          */
4315         protected VolatileImage[] backBuffers; // = null
4316         /**
4317          * Whether or not the drawing buffer has been recently restored from
4318          * a lost state.
4319          */
4320         protected boolean validatedContents; // = false
4321 
4322         /**
4323          * The width of the back buffers
4324          */
4325         protected int width;
4326 
4327         /**
4328          * The height of the back buffers
4329          */
4330         protected int height;
4331 
4332         /**
4333          * Insets for the hosting Component.  The size of the back buffer
4334          * is constrained by these.
4335          */
4336         private Insets insets;
4337 
4338         /**
4339          * Creates a new blt buffer strategy around a component
4340          * @param numBuffers number of buffers to create, including the
4341          * front buffer
4342          * @param caps the capabilities of the buffers
4343          */
4344         protected BltBufferStrategy(int numBuffers, BufferCapabilities caps) {
4345             this.caps = caps;
4346             createBackBuffers(numBuffers - 1);
4347         }
4348 
4349         /**
4350          * {@inheritDoc}
4351          * @since 1.6
4352          */
4353         public void dispose() {
4354             if (backBuffers != null) {
4355                 for (int counter = backBuffers.length - 1; counter >= 0;
4356                      counter--) {
4357                     if (backBuffers[counter] != null) {
4358                         backBuffers[counter].flush();
4359                         backBuffers[counter] = null;
4360                     }
4361                 }
4362             }
4363             if (Component.this.bufferStrategy == this) {
4364                 Component.this.bufferStrategy = null;
4365             }
4366         }
4367 
4368         /**
4369          * Creates the back buffers
4370          *
4371          * @param numBuffers the number of buffers to create
4372          */
4373         protected void createBackBuffers(int numBuffers) {
4374             if (numBuffers == 0) {
4375                 backBuffers = null;
4376             } else {
4377                 // save the current bounds
4378                 width = getWidth();
4379                 height = getHeight();
4380                 insets = getInsets_NoClientCode();
4381                 int iWidth = width - insets.left - insets.right;
4382                 int iHeight = height - insets.top - insets.bottom;
4383 
4384                 // It is possible for the component's width and/or height
4385                 // to be 0 here.  Force the size of the backbuffers to
4386                 // be > 0 so that creating the image won't fail.
4387                 iWidth = Math.max(1, iWidth);
4388                 iHeight = Math.max(1, iHeight);
4389                 if (backBuffers == null) {
4390                     backBuffers = new VolatileImage[numBuffers];
4391                 } else {


4641             return false;
4642         }
4643         public boolean contentsRestored() {
4644             return false;
4645         }
4646         public void show() {
4647             // Do nothing
4648         }
4649     } // Inner class SingleBufferStrategy
4650 
4651     /**
4652      * Sets whether or not paint messages received from the operating system
4653      * should be ignored.  This does not affect paint events generated in
4654      * software by the AWT, unless they are an immediate response to an
4655      * OS-level paint message.
4656      * <p>
4657      * This is useful, for example, if running under full-screen mode and
4658      * better performance is desired, or if page-flipping is used as the
4659      * buffer strategy.
4660      *
4661      * @param ignoreRepaint {@code true} if the paint messages from the OS
4662      *                      should be ignored; otherwise {@code false}
4663      *
4664      * @since 1.4
4665      * @see #getIgnoreRepaint
4666      * @see Canvas#createBufferStrategy
4667      * @see Window#createBufferStrategy
4668      * @see java.awt.image.BufferStrategy
4669      * @see GraphicsDevice#setFullScreenWindow
4670      */
4671     public void setIgnoreRepaint(boolean ignoreRepaint) {
4672         this.ignoreRepaint = ignoreRepaint;
4673     }
4674 
4675     /**
4676      * @return whether or not paint messages received from the operating system
4677      * should be ignored.
4678      *
4679      * @since 1.4
4680      * @see #setIgnoreRepaint
4681      */
4682     public boolean getIgnoreRepaint() {
4683         return ignoreRepaint;
4684     }
4685 
4686     /**
4687      * Checks whether this component "contains" the specified point,
4688      * where <code>x</code> and <code>y</code> are defined to be
4689      * relative to the coordinate system of this component.
4690      *
4691      * @param  x the <i>x</i> coordinate of the point
4692      * @param  y the <i>y</i> coordinate of the point
4693      * @return {@code true} if the point is within the component;
4694      *         otherwise {@code false}
4695      * @see #getComponentAt(int, int)
4696      * @since JDK1.1
4697      */
4698     public boolean contains(int x, int y) {
4699         return inside(x, y);
4700     }
4701 
4702     /**
4703      * Checks whether the point is inside of this component.
4704      *
4705      * @param  x the <i>x</i> coordinate of the point
4706      * @param  y the <i>y</i> coordinate of the point
4707      * @return {@code true} if the point is within the component;
4708      *         otherwise {@code false}
4709      * @deprecated As of JDK version 1.1,
4710      * replaced by contains(int, int).
4711      */
4712     @Deprecated
4713     public boolean inside(int x, int y) {
4714         return (x >= 0) && (x < width) && (y >= 0) && (y < height);
4715     }
4716 
4717     /**
4718      * Checks whether this component "contains" the specified point,
4719      * where the point's <i>x</i> and <i>y</i> coordinates are defined
4720      * to be relative to the coordinate system of this component.
4721      *
4722      * @param  p the point
4723      * @return {@code true} if the point is within the component;
4724      *         otherwise {@code false}
4725      * @throws NullPointerException if {@code p} is {@code null}
4726      * @see    #getComponentAt(Point)
4727      * @since  JDK1.1
4728      */
4729     public boolean contains(Point p) {
4730         return contains(p.x, p.y);
4731     }
4732 
4733     /**
4734      * Determines if this component or one of its immediate
4735      * subcomponents contains the (<i>x</i>,&nbsp;<i>y</i>) location,
4736      * and if so, returns the containing component. This method only
4737      * looks one level deep. If the point (<i>x</i>,&nbsp;<i>y</i>) is
4738      * inside a subcomponent that itself has subcomponents, it does not
4739      * go looking down the subcomponent tree.
4740      * <p>
4741      * The <code>locate</code> method of <code>Component</code> simply
4742      * returns the component itself if the (<i>x</i>,&nbsp;<i>y</i>)
4743      * coordinate location is inside its bounding box, and <code>null</code>
4744      * otherwise.
4745      * @param     x   the <i>x</i> coordinate
4746      * @param     y   the <i>y</i> coordinate
4747      * @return    the component or subcomponent that contains the
4748      *                (<i>x</i>,&nbsp;<i>y</i>) location;
4749      *                <code>null</code> if the location
4750      *                is outside this component
4751      * @see       #contains(int, int)
4752      * @since     JDK1.0
4753      */
4754     public Component getComponentAt(int x, int y) {
4755         return locate(x, y);
4756     }
4757 
4758     /**
4759      * Returns the component occupying the position specified (this component,
4760      * or immediate child component, or null if neither 
4761      * of the first two occupies the location).
4762      *
4763      * @param  x the <i>x</i> coordinate to search for components at
4764      * @param  y the <i>y</i> coordinate to search for components at
4765      * @return the component at the specified location or {@code null}
4766      * @deprecated As of JDK version 1.1,
4767      * replaced by getComponentAt(int, int).
4768      */
4769     @Deprecated
4770     public Component locate(int x, int y) {
4771         return contains(x, y) ? this : null;
4772     }
4773 
4774     /**
4775      * Returns the component or subcomponent that contains the
4776      * specified point.
4777      * @param  p the point
4778      * @return the component at the specified location or {@code null}
4779      * @see java.awt.Component#contains
4780      * @since JDK1.1
4781      */
4782     public Component getComponentAt(Point p) {
4783         return getComponentAt(p.x, p.y);
4784     }
4785 
4786     /**
4787      * @param  e the event to deliver
4788      * @deprecated As of JDK version 1.1,
4789      * replaced by <code>dispatchEvent(AWTEvent e)</code>.
4790      */
4791     @Deprecated
4792     public void deliverEvent(Event e) {
4793         postEvent(e);
4794     }
4795 
4796     /**
4797      * Dispatches an event to this component or one of its sub components.
4798      * Calls <code>processEvent</code> before returning for 1.1-style
4799      * events which have been enabled for the <code>Component</code>.
4800      * @param e the event
4801      */
4802     public final void dispatchEvent(AWTEvent e) {
4803         dispatchEventImpl(e);
4804     }
4805 
4806     @SuppressWarnings("deprecation")
4807     void dispatchEventImpl(AWTEvent e) {


6818      * @see         #addHierarchyBoundsListener
6819      * @see         #enableEvents
6820      * @since       1.3
6821      */
6822     protected void processHierarchyBoundsEvent(HierarchyEvent e) {
6823         HierarchyBoundsListener listener = hierarchyBoundsListener;
6824         if (listener != null) {
6825             int id = e.getID();
6826             switch (id) {
6827               case HierarchyEvent.ANCESTOR_MOVED:
6828                   listener.ancestorMoved(e);
6829                   break;
6830               case HierarchyEvent.ANCESTOR_RESIZED:
6831                   listener.ancestorResized(e);
6832                   break;
6833             }
6834         }
6835     }
6836 
6837     /**
6838      * @param  evt the event to handle
6839      * @return {@code true} if the event was handled, {@code false} otherwise
6840      * @deprecated As of JDK version 1.1
6841      * replaced by processEvent(AWTEvent).
6842      */
6843     @Deprecated
6844     public boolean handleEvent(Event evt) {
6845         switch (evt.id) {
6846           case Event.MOUSE_ENTER:
6847               return mouseEnter(evt, evt.x, evt.y);
6848 
6849           case Event.MOUSE_EXIT:
6850               return mouseExit(evt, evt.x, evt.y);
6851 
6852           case Event.MOUSE_MOVE:
6853               return mouseMove(evt, evt.x, evt.y);
6854 
6855           case Event.MOUSE_DOWN:
6856               return mouseDown(evt, evt.x, evt.y);
6857 
6858           case Event.MOUSE_DRAG:
6859               return mouseDrag(evt, evt.x, evt.y);


6863 
6864           case Event.KEY_PRESS:
6865           case Event.KEY_ACTION:
6866               return keyDown(evt, evt.key);
6867 
6868           case Event.KEY_RELEASE:
6869           case Event.KEY_ACTION_RELEASE:
6870               return keyUp(evt, evt.key);
6871 
6872           case Event.ACTION_EVENT:
6873               return action(evt, evt.arg);
6874           case Event.GOT_FOCUS:
6875               return gotFocus(evt, evt.arg);
6876           case Event.LOST_FOCUS:
6877               return lostFocus(evt, evt.arg);
6878         }
6879         return false;
6880     }
6881 
6882     /**
6883      * @param  evt the event to handle
6884      * @param  x the x coordinate
6885      * @param  y the y coordinate
6886      * @return {@code false}
6887      * @deprecated As of JDK version 1.1,
6888      * replaced by processMouseEvent(MouseEvent).
6889      */
6890     @Deprecated
6891     public boolean mouseDown(Event evt, int x, int y) {
6892         return false;
6893     }
6894 
6895     /**
6896      * @param  evt the event to handle
6897      * @param  x the x coordinate
6898      * @param  y the y coordinate
6899      * @return {@code false}
6900      * @deprecated As of JDK version 1.1,
6901      * replaced by processMouseMotionEvent(MouseEvent).
6902      */
6903     @Deprecated
6904     public boolean mouseDrag(Event evt, int x, int y) {
6905         return false;
6906     }
6907 
6908     /**
6909      * @param  evt the event to handle
6910      * @param  x the x coordinate
6911      * @param  y the y coordinate
6912      * @return {@code false}
6913      * @deprecated As of JDK version 1.1,
6914      * replaced by processMouseEvent(MouseEvent).
6915      */
6916     @Deprecated
6917     public boolean mouseUp(Event evt, int x, int y) {
6918         return false;
6919     }
6920 
6921     /**
6922      * @param  evt the event to handle
6923      * @param  x the x coordinate
6924      * @param  y the y coordinate
6925      * @return {@code false}
6926      * @deprecated As of JDK version 1.1,
6927      * replaced by processMouseMotionEvent(MouseEvent).
6928      */
6929     @Deprecated
6930     public boolean mouseMove(Event evt, int x, int y) {
6931         return false;
6932     }
6933 
6934     /**
6935      * @param  evt the event to handle
6936      * @param  x the x coordinate
6937      * @param  y the y coordinate
6938      * @return {@code false}
6939      * @deprecated As of JDK version 1.1,
6940      * replaced by processMouseEvent(MouseEvent).
6941      */
6942     @Deprecated
6943     public boolean mouseEnter(Event evt, int x, int y) {
6944         return false;
6945     }
6946 
6947     /**
6948      * @param  evt the event to handle
6949      * @param  x the x coordinate
6950      * @param  y the y coordinate
6951      * @return {@code false}
6952      * @deprecated As of JDK version 1.1,
6953      * replaced by processMouseEvent(MouseEvent).
6954      */
6955     @Deprecated
6956     public boolean mouseExit(Event evt, int x, int y) {
6957         return false;
6958     }
6959 
6960     /**
6961      * @param  evt the event to handle
6962      * @param  key the key pressed
6963      * @return {@code false}
6964      * @deprecated As of JDK version 1.1,
6965      * replaced by processKeyEvent(KeyEvent).
6966      */
6967     @Deprecated
6968     public boolean keyDown(Event evt, int key) {
6969         return false;
6970     }
6971 
6972     /**
6973      * @param  evt the event to handle
6974      * @param  key the key pressed
6975      * @return {@code false}
6976      * @deprecated As of JDK version 1.1,
6977      * replaced by processKeyEvent(KeyEvent).
6978      */
6979     @Deprecated
6980     public boolean keyUp(Event evt, int key) {
6981         return false;
6982     }
6983 
6984     /**
6985      * @param  evt the event to handle
6986      * @param  what the object acted on
6987      * @return {@code false}
6988      * @deprecated As of JDK version 1.1,
6989      * should register this component as ActionListener on component
6990      * which fires action events.
6991      */
6992     @Deprecated
6993     public boolean action(Event evt, Object what) {
6994         return false;
6995     }
6996 
6997     /**
6998      * Makes this <code>Component</code> displayable by connecting it to a
6999      * native screen resource.
7000      * This method is called internally by the toolkit and should
7001      * not be called directly by programs.
7002      * <p>
7003      * This method changes layout-related information, and therefore,
7004      * invalidates the component hierarchy.
7005      *
7006      * @see       #isDisplayable
7007      * @see       #removeNotify


7177                 // (or has no shape at all).
7178                 this.compoundShape = null;
7179             }
7180 
7181             if (hierarchyListener != null ||
7182                 (eventMask & AWTEvent.HIERARCHY_EVENT_MASK) != 0 ||
7183                 Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK)) {
7184                 HierarchyEvent e =
7185                     new HierarchyEvent(this, HierarchyEvent.HIERARCHY_CHANGED,
7186                                        this, parent,
7187                                        HierarchyEvent.DISPLAYABILITY_CHANGED |
7188                                        ((isRecursivelyVisible())
7189                                         ? HierarchyEvent.SHOWING_CHANGED
7190                                         : 0));
7191                 dispatchEvent(e);
7192             }
7193         }
7194     }
7195 
7196     /**
7197      * @param  evt the event to handle
7198      * @param  what the object focused
7199      * @return  {@code false}
7200      * @deprecated As of JDK version 1.1,
7201      * replaced by processFocusEvent(FocusEvent).
7202      */
7203     @Deprecated
7204     public boolean gotFocus(Event evt, Object what) {
7205         return false;
7206     }
7207 
7208     /**
7209      * @param evt  the event to handle
7210      * @param what the object focused
7211      * @return  {@code false}
7212      * @deprecated As of JDK version 1.1,
7213      * replaced by processFocusEvent(FocusEvent).
7214      */
7215     @Deprecated
7216     public boolean lostFocus(Event evt, Object what) {
7217         return false;
7218     }
7219 
7220     /**
7221      * Returns whether this <code>Component</code> can become the focus
7222      * owner.
7223      *
7224      * @return <code>true</code> if this <code>Component</code> is
7225      * focusable; <code>false</code> otherwise
7226      * @see #setFocusable
7227      * @since JDK1.1
7228      * @deprecated As of 1.4, replaced by <code>isFocusable()</code>.
7229      */
7230     @Deprecated
7231     public boolean isFocusTraversable() {


8503      *
8504      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
8505      * @see #getPropertyChangeListeners(java.lang.String)
8506      * @see #removePropertyChangeListener(java.beans.PropertyChangeListener)
8507      */
8508     public void removePropertyChangeListener(
8509                                                           String propertyName,
8510                                                           PropertyChangeListener listener) {
8511         synchronized (getObjectLock()) {
8512             if (listener == null || changeSupport == null) {
8513                 return;
8514             }
8515             changeSupport.removePropertyChangeListener(propertyName, listener);
8516         }
8517     }
8518 
8519     /**
8520      * Returns an array of all the listeners which have been associated
8521      * with the named property.
8522      *
8523      * @param  propertyName the property name
8524      *
8525      * @return all of the <code>PropertyChangeListener</code>s associated with
8526      *         the named property; if no such listeners have been added or
8527      *         if <code>propertyName</code> is <code>null</code>, an empty
8528      *         array is returned
8529      *
8530      * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
8531      * @see #removePropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
8532      * @see #getPropertyChangeListeners
8533      * @since 1.4
8534      */
8535     public PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {

8536         synchronized (getObjectLock()) {
8537             if (changeSupport == null) {
8538                 return new PropertyChangeListener[0];
8539             }
8540             return changeSupport.getPropertyChangeListeners(propertyName);
8541         }
8542     }
8543 
8544     /**
8545      * Support for reporting bound property changes for Object properties.
8546      * This method can be called when a bound property has changed and it will
8547      * send the appropriate PropertyChangeEvent to any registered
8548      * PropertyChangeListeners.
8549      *
8550      * @param propertyName the property whose value has changed
8551      * @param oldValue the property's previous value
8552      * @param newValue the property's new value
8553      */
8554     protected void firePropertyChange(String propertyName,
8555                                       Object oldValue, Object newValue) {


8993      * Sets the language-sensitive orientation that is to be used to order
8994      * the elements or text within this component.  Language-sensitive
8995      * <code>LayoutManager</code> and <code>Component</code>
8996      * subclasses will use this property to
8997      * determine how to lay out and draw components.
8998      * <p>
8999      * At construction time, a component's orientation is set to
9000      * <code>ComponentOrientation.UNKNOWN</code>,
9001      * indicating that it has not been specified
9002      * explicitly.  The UNKNOWN orientation behaves the same as
9003      * <code>ComponentOrientation.LEFT_TO_RIGHT</code>.
9004      * <p>
9005      * To set the orientation of a single component, use this method.
9006      * To set the orientation of an entire component
9007      * hierarchy, use
9008      * {@link #applyComponentOrientation applyComponentOrientation}.
9009      * <p>
9010      * This method changes layout-related information, and therefore,
9011      * invalidates the component hierarchy.
9012      *
9013      * @param  o the orientation to be set
9014      *
9015      * @see ComponentOrientation
9016      * @see #invalidate
9017      *
9018      * @author Laura Werner, IBM
9019      * @beaninfo
9020      *       bound: true
9021      */
9022     public void setComponentOrientation(ComponentOrientation o) {
9023         ComponentOrientation oldValue = componentOrientation;
9024         componentOrientation = o;
9025 
9026         // This is a bound property, so report the change to
9027         // any registered listeners.  (Cheap if there are none.)
9028         firePropertyChange("componentOrientation", oldValue, o);
9029 
9030         // This could change the preferred size of the Component.
9031         invalidateIfValid();
9032     }
9033 
9034     /**
9035      * Retrieves the language-sensitive orientation that is to be used to order
9036      * the elements or text within this component.  <code>LayoutManager</code>
9037      * and <code>Component</code>
9038      * subclasses that wish to respect orientation should call this method to
9039      * get the component's orientation before performing layout or drawing.
9040      *
9041      * @return the orientation to order the elements or text
9042      * @see ComponentOrientation
9043      *
9044      * @author Laura Werner, IBM
9045      */
9046     public ComponentOrientation getComponentOrientation() {
9047         return componentOrientation;
9048     }
9049 
9050     /**
9051      * Sets the <code>ComponentOrientation</code> property of this component
9052      * and all components contained within it.
9053      * <p>
9054      * This method changes layout-related information, and therefore,
9055      * invalidates the component hierarchy.
9056      *
9057      *
9058      * @param orientation the new component orientation of this component and
9059      *        the components contained within it.
9060      * @exception NullPointerException if <code>orientation</code> is null.
9061      * @see #setComponentOrientation


9179      */
9180     protected abstract class AccessibleAWTComponent extends AccessibleContext
9181         implements Serializable, AccessibleComponent {
9182 
9183         private static final long serialVersionUID = 642321655757800191L;
9184 
9185         /**
9186          * Though the class is abstract, this should be called by
9187          * all sub-classes.
9188          */
9189         protected AccessibleAWTComponent() {
9190         }
9191 
9192         /**
9193          * Number of PropertyChangeListener objects registered. It's used
9194          * to add/remove ComponentListener and FocusListener to track
9195          * target Component's state.
9196          */
9197         private volatile transient int propertyListenersCount = 0;
9198 
9199         /**
9200          * A component listener to track show/hide/resize events
9201          * and convert them to PropertyChange events.
9202          */
9203         protected ComponentListener accessibleAWTComponentHandler = null;
9204 
9205         /**
9206          * A listener to track focus events
9207          * and convert them to PropertyChange events.
9208          */
9209         protected FocusListener accessibleAWTFocusHandler = null;
9210 
9211         /**
9212          * Fire PropertyChange listener, if one is registered,
9213          * when shown/hidden..
9214          * @since 1.3
9215          */
9216         protected class AccessibleAWTComponentHandler implements ComponentListener {
9217             public void componentHidden(ComponentEvent e)  {
9218                 if (accessibleContext != null) {
9219                     accessibleContext.firePropertyChange(
9220                                                          AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
9221                                                          AccessibleState.VISIBLE, null);
9222                 }
9223             }
9224 
9225             public void componentShown(ComponentEvent e)  {
9226                 if (accessibleContext != null) {
9227                     accessibleContext.firePropertyChange(
9228                                                          AccessibleContext.ACCESSIBLE_STATE_PROPERTY,