1016 |
1016 |
1017 /** |
1017 /** |
1018 * Gets the name of the component. |
1018 * Gets the name of the component. |
1019 * @return this component's name |
1019 * @return this component's name |
1020 * @see #setName |
1020 * @see #setName |
1021 * @since JDK1.1 |
1021 * @since 1.1 |
1022 */ |
1022 */ |
1023 public String getName() { |
1023 public String getName() { |
1024 if (name == null && !nameExplicitlySet) { |
1024 if (name == null && !nameExplicitlySet) { |
1025 synchronized(getObjectLock()) { |
1025 synchronized(getObjectLock()) { |
1026 if (name == null && !nameExplicitlySet) |
1026 if (name == null && !nameExplicitlySet) |
1033 /** |
1033 /** |
1034 * Sets the name of the component to the specified string. |
1034 * Sets the name of the component to the specified string. |
1035 * @param name the string that is to be this |
1035 * @param name the string that is to be this |
1036 * component's name |
1036 * component's name |
1037 * @see #getName |
1037 * @see #getName |
1038 * @since JDK1.1 |
1038 * @since 1.1 |
1039 */ |
1039 */ |
1040 public void setName(String name) { |
1040 public void setName(String name) { |
1041 String oldName; |
1041 String oldName; |
1042 synchronized(getObjectLock()) { |
1042 synchronized(getObjectLock()) { |
1043 oldName = this.name; |
1043 oldName = this.name; |
1219 * Gets the toolkit of this component. Note that |
1219 * Gets the toolkit of this component. Note that |
1220 * the frame that contains a component controls which |
1220 * the frame that contains a component controls which |
1221 * toolkit is used by that component. Therefore if the component |
1221 * toolkit is used by that component. Therefore if the component |
1222 * is moved from one frame to another, the toolkit it uses may change. |
1222 * is moved from one frame to another, the toolkit it uses may change. |
1223 * @return the toolkit of this component |
1223 * @return the toolkit of this component |
1224 * @since JDK1.0 |
1224 * @since 1.0 |
1225 */ |
1225 */ |
1226 public Toolkit getToolkit() { |
1226 public Toolkit getToolkit() { |
1227 return getToolkitImpl(); |
1227 return getToolkitImpl(); |
1228 } |
1228 } |
1229 |
1229 |
1248 * is fully realized, all its components will be valid. |
1248 * is fully realized, all its components will be valid. |
1249 * @return <code>true</code> if the component is valid, <code>false</code> |
1249 * @return <code>true</code> if the component is valid, <code>false</code> |
1250 * otherwise |
1250 * otherwise |
1251 * @see #validate |
1251 * @see #validate |
1252 * @see #invalidate |
1252 * @see #invalidate |
1253 * @since JDK1.0 |
1253 * @since 1.0 |
1254 */ |
1254 */ |
1255 public boolean isValid() { |
1255 public boolean isValid() { |
1256 return (peer != null) && valid; |
1256 return (peer != null) && valid; |
1257 } |
1257 } |
1258 |
1258 |
1290 * initially visible, with the exception of top level components such |
1290 * initially visible, with the exception of top level components such |
1291 * as <code>Frame</code> objects. |
1291 * as <code>Frame</code> objects. |
1292 * @return <code>true</code> if the component is visible, |
1292 * @return <code>true</code> if the component is visible, |
1293 * <code>false</code> otherwise |
1293 * <code>false</code> otherwise |
1294 * @see #setVisible |
1294 * @see #setVisible |
1295 * @since JDK1.0 |
1295 * @since 1.0 |
1296 */ |
1296 */ |
1297 @Transient |
1297 @Transient |
1298 public boolean isVisible() { |
1298 public boolean isVisible() { |
1299 return isVisible_NoClientCode(); |
1299 return isVisible_NoClientCode(); |
1300 } |
1300 } |
1417 * {@code Container}. |
1417 * {@code Container}. |
1418 * </ul> |
1418 * </ul> |
1419 * @return <code>true</code> if the component is showing, |
1419 * @return <code>true</code> if the component is showing, |
1420 * <code>false</code> otherwise |
1420 * <code>false</code> otherwise |
1421 * @see #setVisible |
1421 * @see #setVisible |
1422 * @since JDK1.0 |
1422 * @since 1.0 |
1423 */ |
1423 */ |
1424 public boolean isShowing() { |
1424 public boolean isShowing() { |
1425 if (visible && (peer != null)) { |
1425 if (visible && (peer != null)) { |
1426 Container parent = this.parent; |
1426 Container parent = this.parent; |
1427 return (parent == null) || parent.isShowing(); |
1427 return (parent == null) || parent.isShowing(); |
1435 * enabled initially by default. A component may be enabled or disabled by |
1435 * enabled initially by default. A component may be enabled or disabled by |
1436 * calling its <code>setEnabled</code> method. |
1436 * calling its <code>setEnabled</code> method. |
1437 * @return <code>true</code> if the component is enabled, |
1437 * @return <code>true</code> if the component is enabled, |
1438 * <code>false</code> otherwise |
1438 * <code>false</code> otherwise |
1439 * @see #setEnabled |
1439 * @see #setEnabled |
1440 * @since JDK1.0 |
1440 * @since 1.0 |
1441 */ |
1441 */ |
1442 public boolean isEnabled() { |
1442 public boolean isEnabled() { |
1443 return isEnabledImpl(); |
1443 return isEnabledImpl(); |
1444 } |
1444 } |
1445 |
1445 |
1737 * Gets the foreground color of this component. |
1737 * Gets the foreground color of this component. |
1738 * @return this component's foreground color; if this component does |
1738 * @return this component's foreground color; if this component does |
1739 * not have a foreground color, the foreground color of its parent |
1739 * not have a foreground color, the foreground color of its parent |
1740 * is returned |
1740 * is returned |
1741 * @see #setForeground |
1741 * @see #setForeground |
1742 * @since JDK1.0 |
1742 * @since 1.0 |
1743 * @beaninfo |
1743 * @beaninfo |
1744 * bound: true |
1744 * bound: true |
1745 */ |
1745 */ |
1746 @Transient |
1746 @Transient |
1747 public Color getForeground() { |
1747 public Color getForeground() { |
1758 * @param c the color to become this component's |
1758 * @param c the color to become this component's |
1759 * foreground color; if this parameter is <code>null</code> |
1759 * foreground color; if this parameter is <code>null</code> |
1760 * then this component will inherit |
1760 * then this component will inherit |
1761 * the foreground color of its parent |
1761 * the foreground color of its parent |
1762 * @see #getForeground |
1762 * @see #getForeground |
1763 * @since JDK1.0 |
1763 * @since 1.0 |
1764 */ |
1764 */ |
1765 public void setForeground(Color c) { |
1765 public void setForeground(Color c) { |
1766 Color oldColor = foreground; |
1766 Color oldColor = foreground; |
1767 ComponentPeer peer = this.peer; |
1767 ComponentPeer peer = this.peer; |
1768 foreground = c; |
1768 foreground = c; |
1794 * Gets the background color of this component. |
1794 * Gets the background color of this component. |
1795 * @return this component's background color; if this component does |
1795 * @return this component's background color; if this component does |
1796 * not have a background color, |
1796 * not have a background color, |
1797 * the background color of its parent is returned |
1797 * the background color of its parent is returned |
1798 * @see #setBackground |
1798 * @see #setBackground |
1799 * @since JDK1.0 |
1799 * @since 1.0 |
1800 */ |
1800 */ |
1801 @Transient |
1801 @Transient |
1802 public Color getBackground() { |
1802 public Color getBackground() { |
1803 Color background = this.background; |
1803 Color background = this.background; |
1804 if (background != null) { |
1804 if (background != null) { |
1817 * |
1817 * |
1818 * @param c the color to become this component's color; |
1818 * @param c the color to become this component's color; |
1819 * if this parameter is <code>null</code>, then this |
1819 * if this parameter is <code>null</code>, then this |
1820 * component will inherit the background color of its parent |
1820 * component will inherit the background color of its parent |
1821 * @see #getBackground |
1821 * @see #getBackground |
1822 * @since JDK1.0 |
1822 * @since 1.0 |
1823 * @beaninfo |
1823 * @beaninfo |
1824 * bound: true |
1824 * bound: true |
1825 */ |
1825 */ |
1826 public void setBackground(Color c) { |
1826 public void setBackground(Color c) { |
1827 Color oldColor = background; |
1827 Color oldColor = background; |
1854 /** |
1854 /** |
1855 * Gets the font of this component. |
1855 * Gets the font of this component. |
1856 * @return this component's font; if a font has not been set |
1856 * @return this component's font; if a font has not been set |
1857 * for this component, the font of its parent is returned |
1857 * for this component, the font of its parent is returned |
1858 * @see #setFont |
1858 * @see #setFont |
1859 * @since JDK1.0 |
1859 * @since 1.0 |
1860 */ |
1860 */ |
1861 @Transient |
1861 @Transient |
1862 public Font getFont() { |
1862 public Font getFont() { |
1863 return getFont_NoClientCode(); |
1863 return getFont_NoClientCode(); |
1864 } |
1864 } |
1885 * @param f the font to become this component's font; |
1885 * @param f the font to become this component's font; |
1886 * if this parameter is <code>null</code> then this |
1886 * if this parameter is <code>null</code> then this |
1887 * component will inherit the font of its parent |
1887 * component will inherit the font of its parent |
1888 * @see #getFont |
1888 * @see #getFont |
1889 * @see #invalidate |
1889 * @see #invalidate |
1890 * @since JDK1.0 |
1890 * @since 1.0 |
1891 * @beaninfo |
1891 * @beaninfo |
1892 * bound: true |
1892 * bound: true |
1893 */ |
1893 */ |
1894 public void setFont(Font f) { |
1894 public void setFont(Font f) { |
1895 Font oldFont, newFont; |
1895 Font oldFont, newFont; |
1938 * @see #setLocale |
1938 * @see #setLocale |
1939 * @exception IllegalComponentStateException if the <code>Component</code> |
1939 * @exception IllegalComponentStateException if the <code>Component</code> |
1940 * does not have its own locale and has not yet been added to |
1940 * does not have its own locale and has not yet been added to |
1941 * a containment hierarchy such that the locale can be determined |
1941 * a containment hierarchy such that the locale can be determined |
1942 * from the containing parent |
1942 * from the containing parent |
1943 * @since JDK1.1 |
1943 * @since 1.1 |
1944 */ |
1944 */ |
1945 public Locale getLocale() { |
1945 public Locale getLocale() { |
1946 Locale locale = this.locale; |
1946 Locale locale = this.locale; |
1947 if (locale != null) { |
1947 if (locale != null) { |
1948 return locale; |
1948 return locale; |
1984 * the component on the output device. |
1984 * the component on the output device. |
1985 * @return the color model used by this component |
1985 * @return the color model used by this component |
1986 * @see java.awt.image.ColorModel |
1986 * @see java.awt.image.ColorModel |
1987 * @see java.awt.peer.ComponentPeer#getColorModel() |
1987 * @see java.awt.peer.ComponentPeer#getColorModel() |
1988 * @see Toolkit#getColorModel() |
1988 * @see Toolkit#getColorModel() |
1989 * @since JDK1.0 |
1989 * @since 1.0 |
1990 */ |
1990 */ |
1991 public ColorModel getColorModel() { |
1991 public ColorModel getColorModel() { |
1992 ComponentPeer peer = this.peer; |
1992 ComponentPeer peer = this.peer; |
1993 if ((peer != null) && ! (peer instanceof LightweightPeer)) { |
1993 if ((peer != null) && ! (peer instanceof LightweightPeer)) { |
1994 return peer.getColorModel(); |
1994 return peer.getColorModel(); |
2014 * @return an instance of <code>Point</code> representing |
2014 * @return an instance of <code>Point</code> representing |
2015 * the top-left corner of the component's bounds in |
2015 * the top-left corner of the component's bounds in |
2016 * the coordinate space of the component's parent |
2016 * the coordinate space of the component's parent |
2017 * @see #setLocation |
2017 * @see #setLocation |
2018 * @see #getLocationOnScreen |
2018 * @see #getLocationOnScreen |
2019 * @since JDK1.1 |
2019 * @since 1.1 |
2020 */ |
2020 */ |
2021 public Point getLocation() { |
2021 public Point getLocation() { |
2022 return location(); |
2022 return location(); |
2023 } |
2023 } |
2024 |
2024 |
2141 * field of the <code>Dimension</code> object contains |
2141 * field of the <code>Dimension</code> object contains |
2142 * this component's width. |
2142 * this component's width. |
2143 * @return a <code>Dimension</code> object that indicates the |
2143 * @return a <code>Dimension</code> object that indicates the |
2144 * size of this component |
2144 * size of this component |
2145 * @see #setSize |
2145 * @see #setSize |
2146 * @since JDK1.1 |
2146 * @since 1.1 |
2147 */ |
2147 */ |
2148 public Dimension getSize() { |
2148 public Dimension getSize() { |
2149 return size(); |
2149 return size(); |
2150 } |
2150 } |
2151 |
2151 |
2168 * @param width the new width of this component in pixels |
2168 * @param width the new width of this component in pixels |
2169 * @param height the new height of this component in pixels |
2169 * @param height the new height of this component in pixels |
2170 * @see #getSize |
2170 * @see #getSize |
2171 * @see #setBounds |
2171 * @see #setBounds |
2172 * @see #invalidate |
2172 * @see #invalidate |
2173 * @since JDK1.1 |
2173 * @since 1.1 |
2174 */ |
2174 */ |
2175 public void setSize(int width, int height) { |
2175 public void setSize(int width, int height) { |
2176 resize(width, height); |
2176 resize(width, height); |
2177 } |
2177 } |
2178 |
2178 |
2256 * @see #setLocation(int, int) |
2256 * @see #setLocation(int, int) |
2257 * @see #setLocation(Point) |
2257 * @see #setLocation(Point) |
2258 * @see #setSize(int, int) |
2258 * @see #setSize(int, int) |
2259 * @see #setSize(Dimension) |
2259 * @see #setSize(Dimension) |
2260 * @see #invalidate |
2260 * @see #invalidate |
2261 * @since JDK1.1 |
2261 * @since 1.1 |
2262 */ |
2262 */ |
2263 public void setBounds(int x, int y, int width, int height) { |
2263 public void setBounds(int x, int y, int width, int height) { |
2264 reshape(x, y, width, height); |
2264 reshape(x, y, width, height); |
2265 } |
2265 } |
2266 |
2266 |
2400 * @see #setLocation(int, int) |
2400 * @see #setLocation(int, int) |
2401 * @see #setLocation(Point) |
2401 * @see #setLocation(Point) |
2402 * @see #setSize(int, int) |
2402 * @see #setSize(int, int) |
2403 * @see #setSize(Dimension) |
2403 * @see #setSize(Dimension) |
2404 * @see #invalidate |
2404 * @see #invalidate |
2405 * @since JDK1.1 |
2405 * @since 1.1 |
2406 */ |
2406 */ |
2407 public void setBounds(Rectangle r) { |
2407 public void setBounds(Rectangle r) { |
2408 setBounds(r.x, r.y, r.width, r.height); |
2408 setBounds(r.x, r.y, r.width, r.height); |
2409 } |
2409 } |
2410 |
2410 |
2881 * |
2881 * |
2882 * @see #invalidate |
2882 * @see #invalidate |
2883 * @see #doLayout() |
2883 * @see #doLayout() |
2884 * @see LayoutManager |
2884 * @see LayoutManager |
2885 * @see Container#validate |
2885 * @see Container#validate |
2886 * @since JDK1.0 |
2886 * @since 1.0 |
2887 */ |
2887 */ |
2888 public void validate() { |
2888 public void validate() { |
2889 synchronized (getTreeLock()) { |
2889 synchronized (getTreeLock()) { |
2890 ComponentPeer peer = this.peer; |
2890 ComponentPeer peer = this.peer; |
2891 boolean wasValid = isValid(); |
2891 boolean wasValid = isValid(); |
2924 * |
2924 * |
2925 * @see #validate |
2925 * @see #validate |
2926 * @see #doLayout |
2926 * @see #doLayout |
2927 * @see LayoutManager |
2927 * @see LayoutManager |
2928 * @see java.awt.Container#isValidateRoot |
2928 * @see java.awt.Container#isValidateRoot |
2929 * @since JDK1.0 |
2929 * @since 1.0 |
2930 */ |
2930 */ |
2931 public void invalidate() { |
2931 public void invalidate() { |
2932 synchronized (getTreeLock()) { |
2932 synchronized (getTreeLock()) { |
2933 /* Nullify cached layout and size information. |
2933 /* Nullify cached layout and size information. |
2934 * For efficiency, propagate invalidate() upwards only if |
2934 * For efficiency, propagate invalidate() upwards only if |
3019 * return <code>null</code> if this component is currently not |
3019 * return <code>null</code> if this component is currently not |
3020 * displayable. |
3020 * displayable. |
3021 * @return a graphics context for this component, or <code>null</code> |
3021 * @return a graphics context for this component, or <code>null</code> |
3022 * if it has none |
3022 * if it has none |
3023 * @see #paint |
3023 * @see #paint |
3024 * @since JDK1.0 |
3024 * @since 1.0 |
3025 */ |
3025 */ |
3026 public Graphics getGraphics() { |
3026 public Graphics getGraphics() { |
3027 if (peer instanceof LightweightPeer) { |
3027 if (peer instanceof LightweightPeer) { |
3028 // This is for a lightweight component, need to |
3028 // This is for a lightweight component, need to |
3029 // translate coordinate spaces and clip relative |
3029 // translate coordinate spaces and clip relative |
3083 * @return the font metrics for <code>font</code> |
3083 * @return the font metrics for <code>font</code> |
3084 * @see #getFont |
3084 * @see #getFont |
3085 * @see #getPeer |
3085 * @see #getPeer |
3086 * @see java.awt.peer.ComponentPeer#getFontMetrics(Font) |
3086 * @see java.awt.peer.ComponentPeer#getFontMetrics(Font) |
3087 * @see Toolkit#getFontMetrics(Font) |
3087 * @see Toolkit#getFontMetrics(Font) |
3088 * @since JDK1.0 |
3088 * @since 1.0 |
3089 */ |
3089 */ |
3090 public FontMetrics getFontMetrics(Font font) { |
3090 public FontMetrics getFontMetrics(Font font) { |
3091 // This is an unsupported hack, but left in for a customer. |
3091 // This is an unsupported hack, but left in for a customer. |
3092 // Do not remove. |
3092 // Do not remove. |
3093 FontManager fm = FontManagerFactory.getInstance(); |
3093 FontManager fm = FontManagerFactory.getInstance(); |
3156 * Gets the cursor set in the component. If the component does |
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. |
3157 * not have a cursor set, the cursor of its parent is returned. |
3158 * If no cursor is set in the entire hierarchy, |
3158 * If no cursor is set in the entire hierarchy, |
3159 * <code>Cursor.DEFAULT_CURSOR</code> is returned. |
3159 * <code>Cursor.DEFAULT_CURSOR</code> is returned. |
3160 * @see #setCursor |
3160 * @see #setCursor |
3161 * @since JDK1.1 |
3161 * @since 1.1 |
3162 */ |
3162 */ |
3163 public Cursor getCursor() { |
3163 public Cursor getCursor() { |
3164 return getCursor_NoClientCode(); |
3164 return getCursor_NoClientCode(); |
3165 } |
3165 } |
3166 |
3166 |
3262 * top-left corner of this component. The clipping region of the |
3262 * top-left corner of this component. The clipping region of the |
3263 * graphics context is the bounding rectangle of this component. |
3263 * graphics context is the bounding rectangle of this component. |
3264 * |
3264 * |
3265 * @param g the graphics context to use for painting |
3265 * @param g the graphics context to use for painting |
3266 * @see #paint |
3266 * @see #paint |
3267 * @since JDK1.0 |
3267 * @since 1.0 |
3268 */ |
3268 */ |
3269 public void paintAll(Graphics g) { |
3269 public void paintAll(Graphics g) { |
3270 if (isShowing()) { |
3270 if (isShowing()) { |
3271 GraphicsCallback.PeerPaintCallback.getInstance(). |
3271 GraphicsCallback.PeerPaintCallback.getInstance(). |
3272 runOneComponent(this, new Rectangle(0, 0, width, height), |
3272 runOneComponent(this, new Rectangle(0, 0, width, height), |
3306 * efficient painting code, see |
3306 * efficient painting code, see |
3307 * <a href="http://www.oracle.com/technetwork/java/painting-140037.html">Painting in AWT and Swing</a>. |
3307 * <a href="http://www.oracle.com/technetwork/java/painting-140037.html">Painting in AWT and Swing</a>. |
3308 |
3308 |
3309 * |
3309 * |
3310 * @see #update(Graphics) |
3310 * @see #update(Graphics) |
3311 * @since JDK1.0 |
3311 * @since 1.0 |
3312 */ |
3312 */ |
3313 public void repaint() { |
3313 public void repaint() { |
3314 repaint(0, 0, 0, width, height); |
3314 repaint(0, 0, 0, width, height); |
3315 } |
3315 } |
3316 |
3316 |
3325 * <a href="http://www.oracle.com/technetwork/java/painting-140037.html">Painting in AWT and Swing</a>. |
3325 * <a href="http://www.oracle.com/technetwork/java/painting-140037.html">Painting in AWT and Swing</a>. |
3326 * |
3326 * |
3327 * @param tm maximum time in milliseconds before update |
3327 * @param tm maximum time in milliseconds before update |
3328 * @see #paint |
3328 * @see #paint |
3329 * @see #update(Graphics) |
3329 * @see #update(Graphics) |
3330 * @since JDK1.0 |
3330 * @since 1.0 |
3331 */ |
3331 */ |
3332 public void repaint(long tm) { |
3332 public void repaint(long tm) { |
3333 repaint(tm, 0, 0, width, height); |
3333 repaint(tm, 0, 0, width, height); |
3334 } |
3334 } |
3335 |
3335 |
3349 * @param x the <i>x</i> coordinate |
3349 * @param x the <i>x</i> coordinate |
3350 * @param y the <i>y</i> coordinate |
3350 * @param y the <i>y</i> coordinate |
3351 * @param width the width |
3351 * @param width the width |
3352 * @param height the height |
3352 * @param height the height |
3353 * @see #update(Graphics) |
3353 * @see #update(Graphics) |
3354 * @since JDK1.0 |
3354 * @since 1.0 |
3355 */ |
3355 */ |
3356 public void repaint(int x, int y, int width, int height) { |
3356 public void repaint(int x, int y, int width, int height) { |
3357 repaint(0, x, y, width, height); |
3357 repaint(0, x, y, width, height); |
3358 } |
3358 } |
3359 |
3359 |
3375 * @param x the <i>x</i> coordinate |
3375 * @param x the <i>x</i> coordinate |
3376 * @param y the <i>y</i> coordinate |
3376 * @param y the <i>y</i> coordinate |
3377 * @param width the width |
3377 * @param width the width |
3378 * @param height the height |
3378 * @param height the height |
3379 * @see #update(Graphics) |
3379 * @see #update(Graphics) |
3380 * @since JDK1.0 |
3380 * @since 1.0 |
3381 */ |
3381 */ |
3382 public void repaint(long tm, int x, int y, int width, int height) { |
3382 public void repaint(long tm, int x, int y, int width, int height) { |
3383 if (this.peer instanceof LightweightPeer) { |
3383 if (this.peer instanceof LightweightPeer) { |
3384 // Needs to be translated to parent coordinates since |
3384 // Needs to be translated to parent coordinates since |
3385 // a parent native container provides the actual repaint |
3385 // a parent native container provides the actual repaint |
3428 * (<code>0</code>, <code>0</code>) coordinate point, is the |
3428 * (<code>0</code>, <code>0</code>) coordinate point, is the |
3429 * top-left corner of this component. The clipping region of the |
3429 * top-left corner of this component. The clipping region of the |
3430 * graphics context is the bounding rectangle of this component. |
3430 * graphics context is the bounding rectangle of this component. |
3431 * @param g the graphics context to use for printing |
3431 * @param g the graphics context to use for printing |
3432 * @see #paint(Graphics) |
3432 * @see #paint(Graphics) |
3433 * @since JDK1.0 |
3433 * @since 1.0 |
3434 */ |
3434 */ |
3435 public void print(Graphics g) { |
3435 public void print(Graphics g) { |
3436 paint(g); |
3436 paint(g); |
3437 } |
3437 } |
3438 |
3438 |
3443 * (<code>0</code>, <code>0</code>) coordinate point, is the |
3443 * (<code>0</code>, <code>0</code>) coordinate point, is the |
3444 * top-left corner of this component. The clipping region of the |
3444 * top-left corner of this component. The clipping region of the |
3445 * graphics context is the bounding rectangle of this component. |
3445 * graphics context is the bounding rectangle of this component. |
3446 * @param g the graphics context to use for printing |
3446 * @param g the graphics context to use for printing |
3447 * @see #print(Graphics) |
3447 * @see #print(Graphics) |
3448 * @since JDK1.0 |
3448 * @since 1.0 |
3449 */ |
3449 */ |
3450 public void printAll(Graphics g) { |
3450 public void printAll(Graphics g) { |
3451 if (isShowing()) { |
3451 if (isShowing()) { |
3452 GraphicsCallback.PeerPrintCallback.getInstance(). |
3452 GraphicsCallback.PeerPrintCallback.getInstance(). |
3453 runOneComponent(this, new Rectangle(0, 0, width, height), |
3453 runOneComponent(this, new Rectangle(0, 0, width, height), |
3523 * @see Graphics#drawImage(Image, int, int, Color, java.awt.image.ImageObserver) |
3523 * @see Graphics#drawImage(Image, int, int, Color, java.awt.image.ImageObserver) |
3524 * @see Graphics#drawImage(Image, int, int, java.awt.image.ImageObserver) |
3524 * @see Graphics#drawImage(Image, int, int, java.awt.image.ImageObserver) |
3525 * @see Graphics#drawImage(Image, int, int, int, int, Color, java.awt.image.ImageObserver) |
3525 * @see Graphics#drawImage(Image, int, int, int, int, Color, java.awt.image.ImageObserver) |
3526 * @see Graphics#drawImage(Image, int, int, int, int, java.awt.image.ImageObserver) |
3526 * @see Graphics#drawImage(Image, int, int, int, int, java.awt.image.ImageObserver) |
3527 * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) |
3527 * @see java.awt.image.ImageObserver#imageUpdate(java.awt.Image, int, int, int, int, int) |
3528 * @since JDK1.0 |
3528 * @since 1.0 |
3529 */ |
3529 */ |
3530 public boolean imageUpdate(Image img, int infoflags, |
3530 public boolean imageUpdate(Image img, int infoflags, |
3531 int x, int y, int w, int h) { |
3531 int x, int y, int w, int h) { |
3532 int rate = -1; |
3532 int rate = -1; |
3533 if ((infoflags & (FRAMEBITS|ALLBITS)) != 0) { |
3533 if ((infoflags & (FRAMEBITS|ALLBITS)) != 0) { |
3548 |
3548 |
3549 /** |
3549 /** |
3550 * Creates an image from the specified image producer. |
3550 * Creates an image from the specified image producer. |
3551 * @param producer the image producer |
3551 * @param producer the image producer |
3552 * @return the image produced |
3552 * @return the image produced |
3553 * @since JDK1.0 |
3553 * @since 1.0 |
3554 */ |
3554 */ |
3555 public Image createImage(ImageProducer producer) { |
3555 public Image createImage(ImageProducer producer) { |
3556 ComponentPeer peer = this.peer; |
3556 ComponentPeer peer = this.peer; |
3557 if ((peer != null) && ! (peer instanceof LightweightPeer)) { |
3557 if ((peer != null) && ! (peer instanceof LightweightPeer)) { |
3558 return peer.createImage(producer); |
3558 return peer.createImage(producer); |
3570 * component is not displayable. This will always happen if |
3570 * component is not displayable. This will always happen if |
3571 * <code>GraphicsEnvironment.isHeadless()</code> returns |
3571 * <code>GraphicsEnvironment.isHeadless()</code> returns |
3572 * <code>true</code>. |
3572 * <code>true</code>. |
3573 * @see #isDisplayable |
3573 * @see #isDisplayable |
3574 * @see GraphicsEnvironment#isHeadless |
3574 * @see GraphicsEnvironment#isHeadless |
3575 * @since JDK1.0 |
3575 * @since 1.0 |
3576 */ |
3576 */ |
3577 public Image createImage(int width, int height) { |
3577 public Image createImage(int width, int height) { |
3578 ComponentPeer peer = this.peer; |
3578 ComponentPeer peer = this.peer; |
3579 if (peer instanceof LightweightPeer) { |
3579 if (peer instanceof LightweightPeer) { |
3580 if (parent != null) { return parent.createImage(width, height); } |
3580 if (parent != null) { return parent.createImage(width, height); } |
3641 * prepare a screen representation |
3641 * prepare a screen representation |
3642 * @param observer the <code>ImageObserver</code> object |
3642 * @param observer the <code>ImageObserver</code> object |
3643 * to be notified as the image is being prepared |
3643 * to be notified as the image is being prepared |
3644 * @return <code>true</code> if the image has already been fully |
3644 * @return <code>true</code> if the image has already been fully |
3645 * prepared; <code>false</code> otherwise |
3645 * prepared; <code>false</code> otherwise |
3646 * @since JDK1.0 |
3646 * @since 1.0 |
3647 */ |
3647 */ |
3648 public boolean prepareImage(Image image, ImageObserver observer) { |
3648 public boolean prepareImage(Image image, ImageObserver observer) { |
3649 return prepareImage(image, -1, -1, observer); |
3649 return prepareImage(image, -1, -1, observer); |
3650 } |
3650 } |
3651 |
3651 |
3663 * @param observer the <code>ImageObserver</code> object |
3663 * @param observer the <code>ImageObserver</code> object |
3664 * to be notified as the image is being prepared |
3664 * to be notified as the image is being prepared |
3665 * @return <code>true</code> if the image has already been fully |
3665 * @return <code>true</code> if the image has already been fully |
3666 * prepared; <code>false</code> otherwise |
3666 * prepared; <code>false</code> otherwise |
3667 * @see java.awt.image.ImageObserver |
3667 * @see java.awt.image.ImageObserver |
3668 * @since JDK1.0 |
3668 * @since 1.0 |
3669 */ |
3669 */ |
3670 public boolean prepareImage(Image image, int width, int height, |
3670 public boolean prepareImage(Image image, int width, int height, |
3671 ImageObserver observer) { |
3671 ImageObserver observer) { |
3672 ComponentPeer peer = this.peer; |
3672 ComponentPeer peer = this.peer; |
3673 if (peer instanceof LightweightPeer) { |
3673 if (peer instanceof LightweightPeer) { |
3699 * <code>ImageObserver</code> flags indicating what |
3699 * <code>ImageObserver</code> flags indicating what |
3700 * information about the image is currently available |
3700 * information about the image is currently available |
3701 * @see #prepareImage(Image, int, int, java.awt.image.ImageObserver) |
3701 * @see #prepareImage(Image, int, int, java.awt.image.ImageObserver) |
3702 * @see Toolkit#checkImage(Image, int, int, java.awt.image.ImageObserver) |
3702 * @see Toolkit#checkImage(Image, int, int, java.awt.image.ImageObserver) |
3703 * @see java.awt.image.ImageObserver |
3703 * @see java.awt.image.ImageObserver |
3704 * @since JDK1.0 |
3704 * @since 1.0 |
3705 */ |
3705 */ |
3706 public int checkImage(Image image, ImageObserver observer) { |
3706 public int checkImage(Image image, ImageObserver observer) { |
3707 return checkImage(image, -1, -1, observer); |
3707 return checkImage(image, -1, -1, observer); |
3708 } |
3708 } |
3709 |
3709 |
3735 * <code>ImageObserver</code> flags indicating what |
3735 * <code>ImageObserver</code> flags indicating what |
3736 * information about the image is currently available |
3736 * information about the image is currently available |
3737 * @see #prepareImage(Image, int, int, java.awt.image.ImageObserver) |
3737 * @see #prepareImage(Image, int, int, java.awt.image.ImageObserver) |
3738 * @see Toolkit#checkImage(Image, int, int, java.awt.image.ImageObserver) |
3738 * @see Toolkit#checkImage(Image, int, int, java.awt.image.ImageObserver) |
3739 * @see java.awt.image.ImageObserver |
3739 * @see java.awt.image.ImageObserver |
3740 * @since JDK1.0 |
3740 * @since 1.0 |
3741 */ |
3741 */ |
3742 public int checkImage(Image image, int width, int height, |
3742 public int checkImage(Image image, int width, int height, |
3743 ImageObserver observer) { |
3743 ImageObserver observer) { |
3744 ComponentPeer peer = this.peer; |
3744 ComponentPeer peer = this.peer; |
3745 if (peer instanceof LightweightPeer) { |
3745 if (peer instanceof LightweightPeer) { |
4620 * where <code>x</code> and <code>y</code> are defined to be |
4620 * where <code>x</code> and <code>y</code> are defined to be |
4621 * relative to the coordinate system of this component. |
4621 * relative to the coordinate system of this component. |
4622 * @param x the <i>x</i> coordinate of the point |
4622 * @param x the <i>x</i> coordinate of the point |
4623 * @param y the <i>y</i> coordinate of the point |
4623 * @param y the <i>y</i> coordinate of the point |
4624 * @see #getComponentAt(int, int) |
4624 * @see #getComponentAt(int, int) |
4625 * @since JDK1.1 |
4625 * @since 1.1 |
4626 */ |
4626 */ |
4627 public boolean contains(int x, int y) { |
4627 public boolean contains(int x, int y) { |
4628 return inside(x, y); |
4628 return inside(x, y); |
4629 } |
4629 } |
4630 |
4630 |
4642 * where the point's <i>x</i> and <i>y</i> coordinates are defined |
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. |
4643 * to be relative to the coordinate system of this component. |
4644 * @param p the point |
4644 * @param p the point |
4645 * @throws NullPointerException if {@code p} is {@code null} |
4645 * @throws NullPointerException if {@code p} is {@code null} |
4646 * @see #getComponentAt(Point) |
4646 * @see #getComponentAt(Point) |
4647 * @since JDK1.1 |
4647 * @since 1.1 |
4648 */ |
4648 */ |
4649 public boolean contains(Point p) { |
4649 public boolean contains(Point p) { |
4650 return contains(p.x, p.y); |
4650 return contains(p.x, p.y); |
4651 } |
4651 } |
4652 |
4652 |
4667 * @return the component or subcomponent that contains the |
4667 * @return the component or subcomponent that contains the |
4668 * (<i>x</i>, <i>y</i>) location; |
4668 * (<i>x</i>, <i>y</i>) location; |
4669 * <code>null</code> if the location |
4669 * <code>null</code> if the location |
4670 * is outside this component |
4670 * is outside this component |
4671 * @see #contains(int, int) |
4671 * @see #contains(int, int) |
4672 * @since JDK1.0 |
4672 * @since 1.0 |
4673 */ |
4673 */ |
4674 public Component getComponentAt(int x, int y) { |
4674 public Component getComponentAt(int x, int y) { |
4675 return locate(x, y); |
4675 return locate(x, y); |
4676 } |
4676 } |
4677 |
4677 |
4687 /** |
4687 /** |
4688 * Returns the component or subcomponent that contains the |
4688 * Returns the component or subcomponent that contains the |
4689 * specified point. |
4689 * specified point. |
4690 * @param p the point |
4690 * @param p the point |
4691 * @see java.awt.Component#contains |
4691 * @see java.awt.Component#contains |
4692 * @since JDK1.1 |
4692 * @since 1.1 |
4693 */ |
4693 */ |
4694 public Component getComponentAt(Point p) { |
4694 public Component getComponentAt(Point p) { |
4695 return getComponentAt(p.x, p.y); |
4695 return getComponentAt(p.x, p.y); |
4696 } |
4696 } |
4697 |
4697 |
5222 * @param l the component listener |
5222 * @param l the component listener |
5223 * @see java.awt.event.ComponentEvent |
5223 * @see java.awt.event.ComponentEvent |
5224 * @see java.awt.event.ComponentListener |
5224 * @see java.awt.event.ComponentListener |
5225 * @see #removeComponentListener |
5225 * @see #removeComponentListener |
5226 * @see #getComponentListeners |
5226 * @see #getComponentListeners |
5227 * @since JDK1.1 |
5227 * @since 1.1 |
5228 */ |
5228 */ |
5229 public synchronized void addComponentListener(ComponentListener l) { |
5229 public synchronized void addComponentListener(ComponentListener l) { |
5230 if (l == null) { |
5230 if (l == null) { |
5231 return; |
5231 return; |
5232 } |
5232 } |
5246 * @param l the component listener |
5246 * @param l the component listener |
5247 * @see java.awt.event.ComponentEvent |
5247 * @see java.awt.event.ComponentEvent |
5248 * @see java.awt.event.ComponentListener |
5248 * @see java.awt.event.ComponentListener |
5249 * @see #addComponentListener |
5249 * @see #addComponentListener |
5250 * @see #getComponentListeners |
5250 * @see #getComponentListeners |
5251 * @since JDK1.1 |
5251 * @since 1.1 |
5252 */ |
5252 */ |
5253 public synchronized void removeComponentListener(ComponentListener l) { |
5253 public synchronized void removeComponentListener(ComponentListener l) { |
5254 if (l == null) { |
5254 if (l == null) { |
5255 return; |
5255 return; |
5256 } |
5256 } |
5284 * @param l the focus listener |
5284 * @param l the focus listener |
5285 * @see java.awt.event.FocusEvent |
5285 * @see java.awt.event.FocusEvent |
5286 * @see java.awt.event.FocusListener |
5286 * @see java.awt.event.FocusListener |
5287 * @see #removeFocusListener |
5287 * @see #removeFocusListener |
5288 * @see #getFocusListeners |
5288 * @see #getFocusListeners |
5289 * @since JDK1.1 |
5289 * @since 1.1 |
5290 */ |
5290 */ |
5291 public synchronized void addFocusListener(FocusListener l) { |
5291 public synchronized void addFocusListener(FocusListener l) { |
5292 if (l == null) { |
5292 if (l == null) { |
5293 return; |
5293 return; |
5294 } |
5294 } |
5315 * @param l the focus listener |
5315 * @param l the focus listener |
5316 * @see java.awt.event.FocusEvent |
5316 * @see java.awt.event.FocusEvent |
5317 * @see java.awt.event.FocusListener |
5317 * @see java.awt.event.FocusListener |
5318 * @see #addFocusListener |
5318 * @see #addFocusListener |
5319 * @see #getFocusListeners |
5319 * @see #getFocusListeners |
5320 * @since JDK1.1 |
5320 * @since 1.1 |
5321 */ |
5321 */ |
5322 public synchronized void removeFocusListener(FocusListener l) { |
5322 public synchronized void removeFocusListener(FocusListener l) { |
5323 if (l == null) { |
5323 if (l == null) { |
5324 return; |
5324 return; |
5325 } |
5325 } |
5616 * @param l the key listener. |
5616 * @param l the key listener. |
5617 * @see java.awt.event.KeyEvent |
5617 * @see java.awt.event.KeyEvent |
5618 * @see java.awt.event.KeyListener |
5618 * @see java.awt.event.KeyListener |
5619 * @see #removeKeyListener |
5619 * @see #removeKeyListener |
5620 * @see #getKeyListeners |
5620 * @see #getKeyListeners |
5621 * @since JDK1.1 |
5621 * @since 1.1 |
5622 */ |
5622 */ |
5623 public synchronized void addKeyListener(KeyListener l) { |
5623 public synchronized void addKeyListener(KeyListener l) { |
5624 if (l == null) { |
5624 if (l == null) { |
5625 return; |
5625 return; |
5626 } |
5626 } |
5647 * @param l the key listener |
5647 * @param l the key listener |
5648 * @see java.awt.event.KeyEvent |
5648 * @see java.awt.event.KeyEvent |
5649 * @see java.awt.event.KeyListener |
5649 * @see java.awt.event.KeyListener |
5650 * @see #addKeyListener |
5650 * @see #addKeyListener |
5651 * @see #getKeyListeners |
5651 * @see #getKeyListeners |
5652 * @since JDK1.1 |
5652 * @since 1.1 |
5653 */ |
5653 */ |
5654 public synchronized void removeKeyListener(KeyListener l) { |
5654 public synchronized void removeKeyListener(KeyListener l) { |
5655 if (l == null) { |
5655 if (l == null) { |
5656 return; |
5656 return; |
5657 } |
5657 } |
5685 * @param l the mouse listener |
5685 * @param l the mouse listener |
5686 * @see java.awt.event.MouseEvent |
5686 * @see java.awt.event.MouseEvent |
5687 * @see java.awt.event.MouseListener |
5687 * @see java.awt.event.MouseListener |
5688 * @see #removeMouseListener |
5688 * @see #removeMouseListener |
5689 * @see #getMouseListeners |
5689 * @see #getMouseListeners |
5690 * @since JDK1.1 |
5690 * @since 1.1 |
5691 */ |
5691 */ |
5692 public synchronized void addMouseListener(MouseListener l) { |
5692 public synchronized void addMouseListener(MouseListener l) { |
5693 if (l == null) { |
5693 if (l == null) { |
5694 return; |
5694 return; |
5695 } |
5695 } |
5716 * @param l the mouse listener |
5716 * @param l the mouse listener |
5717 * @see java.awt.event.MouseEvent |
5717 * @see java.awt.event.MouseEvent |
5718 * @see java.awt.event.MouseListener |
5718 * @see java.awt.event.MouseListener |
5719 * @see #addMouseListener |
5719 * @see #addMouseListener |
5720 * @see #getMouseListeners |
5720 * @see #getMouseListeners |
5721 * @since JDK1.1 |
5721 * @since 1.1 |
5722 */ |
5722 */ |
5723 public synchronized void removeMouseListener(MouseListener l) { |
5723 public synchronized void removeMouseListener(MouseListener l) { |
5724 if (l == null) { |
5724 if (l == null) { |
5725 return; |
5725 return; |
5726 } |
5726 } |
5754 * @param l the mouse motion listener |
5754 * @param l the mouse motion listener |
5755 * @see java.awt.event.MouseEvent |
5755 * @see java.awt.event.MouseEvent |
5756 * @see java.awt.event.MouseMotionListener |
5756 * @see java.awt.event.MouseMotionListener |
5757 * @see #removeMouseMotionListener |
5757 * @see #removeMouseMotionListener |
5758 * @see #getMouseMotionListeners |
5758 * @see #getMouseMotionListeners |
5759 * @since JDK1.1 |
5759 * @since 1.1 |
5760 */ |
5760 */ |
5761 public synchronized void addMouseMotionListener(MouseMotionListener l) { |
5761 public synchronized void addMouseMotionListener(MouseMotionListener l) { |
5762 if (l == null) { |
5762 if (l == null) { |
5763 return; |
5763 return; |
5764 } |
5764 } |
5785 * @param l the mouse motion listener |
5785 * @param l the mouse motion listener |
5786 * @see java.awt.event.MouseEvent |
5786 * @see java.awt.event.MouseEvent |
5787 * @see java.awt.event.MouseMotionListener |
5787 * @see java.awt.event.MouseMotionListener |
5788 * @see #addMouseMotionListener |
5788 * @see #addMouseMotionListener |
5789 * @see #getMouseMotionListeners |
5789 * @see #getMouseMotionListeners |
5790 * @since JDK1.1 |
5790 * @since 1.1 |
5791 */ |
5791 */ |
5792 public synchronized void removeMouseMotionListener(MouseMotionListener l) { |
5792 public synchronized void removeMouseMotionListener(MouseMotionListener l) { |
5793 if (l == null) { |
5793 if (l == null) { |
5794 return; |
5794 return; |
5795 } |
5795 } |
6070 * or not a listener is registered. |
6070 * or not a listener is registered. |
6071 * @param eventsToEnable the event mask defining the event types |
6071 * @param eventsToEnable the event mask defining the event types |
6072 * @see #processEvent |
6072 * @see #processEvent |
6073 * @see #disableEvents |
6073 * @see #disableEvents |
6074 * @see AWTEvent |
6074 * @see AWTEvent |
6075 * @since JDK1.1 |
6075 * @since 1.1 |
6076 */ |
6076 */ |
6077 protected final void enableEvents(long eventsToEnable) { |
6077 protected final void enableEvents(long eventsToEnable) { |
6078 long notifyAncestors = 0; |
6078 long notifyAncestors = 0; |
6079 synchronized (this) { |
6079 synchronized (this) { |
6080 if ((eventsToEnable & AWTEvent.HIERARCHY_EVENT_MASK) != 0 && |
6080 if ((eventsToEnable & AWTEvent.HIERARCHY_EVENT_MASK) != 0 && |
6106 /** |
6106 /** |
6107 * Disables the events defined by the specified event mask parameter |
6107 * Disables the events defined by the specified event mask parameter |
6108 * from being delivered to this component. |
6108 * from being delivered to this component. |
6109 * @param eventsToDisable the event mask defining the event types |
6109 * @param eventsToDisable the event mask defining the event types |
6110 * @see #enableEvents |
6110 * @see #enableEvents |
6111 * @since JDK1.1 |
6111 * @since 1.1 |
6112 */ |
6112 */ |
6113 protected final void disableEvents(long eventsToDisable) { |
6113 protected final void disableEvents(long eventsToDisable) { |
6114 long notifyAncestors = 0; |
6114 long notifyAncestors = 0; |
6115 synchronized (this) { |
6115 synchronized (this) { |
6116 if ((eventsToDisable & AWTEvent.HIERARCHY_EVENT_MASK) != 0 && |
6116 if ((eventsToDisable & AWTEvent.HIERARCHY_EVENT_MASK) != 0 && |
6283 * @see #processMouseEvent |
6283 * @see #processMouseEvent |
6284 * @see #processMouseMotionEvent |
6284 * @see #processMouseMotionEvent |
6285 * @see #processInputMethodEvent |
6285 * @see #processInputMethodEvent |
6286 * @see #processHierarchyEvent |
6286 * @see #processHierarchyEvent |
6287 * @see #processMouseWheelEvent |
6287 * @see #processMouseWheelEvent |
6288 * @since JDK1.1 |
6288 * @since 1.1 |
6289 */ |
6289 */ |
6290 protected void processEvent(AWTEvent e) { |
6290 protected void processEvent(AWTEvent e) { |
6291 if (e instanceof FocusEvent) { |
6291 if (e instanceof FocusEvent) { |
6292 processFocusEvent((FocusEvent)e); |
6292 processFocusEvent((FocusEvent)e); |
6293 |
6293 |
6349 * @param e the component event |
6349 * @param e the component event |
6350 * @see java.awt.event.ComponentEvent |
6350 * @see java.awt.event.ComponentEvent |
6351 * @see java.awt.event.ComponentListener |
6351 * @see java.awt.event.ComponentListener |
6352 * @see #addComponentListener |
6352 * @see #addComponentListener |
6353 * @see #enableEvents |
6353 * @see #enableEvents |
6354 * @since JDK1.1 |
6354 * @since 1.1 |
6355 */ |
6355 */ |
6356 protected void processComponentEvent(ComponentEvent e) { |
6356 protected void processComponentEvent(ComponentEvent e) { |
6357 ComponentListener listener = componentListener; |
6357 ComponentListener listener = componentListener; |
6358 if (listener != null) { |
6358 if (listener != null) { |
6359 int id = e.getID(); |
6359 int id = e.getID(); |
6412 * @see java.awt.event.FocusListener |
6412 * @see java.awt.event.FocusListener |
6413 * @see java.awt.KeyboardFocusManager |
6413 * @see java.awt.KeyboardFocusManager |
6414 * @see #addFocusListener |
6414 * @see #addFocusListener |
6415 * @see #enableEvents |
6415 * @see #enableEvents |
6416 * @see #dispatchEvent |
6416 * @see #dispatchEvent |
6417 * @since JDK1.1 |
6417 * @since 1.1 |
6418 */ |
6418 */ |
6419 protected void processFocusEvent(FocusEvent e) { |
6419 protected void processFocusEvent(FocusEvent e) { |
6420 FocusListener listener = focusListener; |
6420 FocusListener listener = focusListener; |
6421 if (listener != null) { |
6421 if (listener != null) { |
6422 int id = e.getID(); |
6422 int id = e.getID(); |
6478 * @see #processEvent |
6478 * @see #processEvent |
6479 * @see #dispatchEvent |
6479 * @see #dispatchEvent |
6480 * @see #addKeyListener |
6480 * @see #addKeyListener |
6481 * @see #enableEvents |
6481 * @see #enableEvents |
6482 * @see #isShowing |
6482 * @see #isShowing |
6483 * @since JDK1.1 |
6483 * @since 1.1 |
6484 */ |
6484 */ |
6485 protected void processKeyEvent(KeyEvent e) { |
6485 protected void processKeyEvent(KeyEvent e) { |
6486 KeyListener listener = keyListener; |
6486 KeyListener listener = keyListener; |
6487 if (listener != null) { |
6487 if (listener != null) { |
6488 int id = e.getID(); |
6488 int id = e.getID(); |
6520 * @param e the mouse event |
6520 * @param e the mouse event |
6521 * @see java.awt.event.MouseEvent |
6521 * @see java.awt.event.MouseEvent |
6522 * @see java.awt.event.MouseListener |
6522 * @see java.awt.event.MouseListener |
6523 * @see #addMouseListener |
6523 * @see #addMouseListener |
6524 * @see #enableEvents |
6524 * @see #enableEvents |
6525 * @since JDK1.1 |
6525 * @since 1.1 |
6526 */ |
6526 */ |
6527 protected void processMouseEvent(MouseEvent e) { |
6527 protected void processMouseEvent(MouseEvent e) { |
6528 MouseListener listener = mouseListener; |
6528 MouseListener listener = mouseListener; |
6529 if (listener != null) { |
6529 if (listener != null) { |
6530 int id = e.getID(); |
6530 int id = e.getID(); |
6568 * @param e the mouse motion event |
6568 * @param e the mouse motion event |
6569 * @see java.awt.event.MouseEvent |
6569 * @see java.awt.event.MouseEvent |
6570 * @see java.awt.event.MouseMotionListener |
6570 * @see java.awt.event.MouseMotionListener |
6571 * @see #addMouseMotionListener |
6571 * @see #addMouseMotionListener |
6572 * @see #enableEvents |
6572 * @see #enableEvents |
6573 * @since JDK1.1 |
6573 * @since 1.1 |
6574 */ |
6574 */ |
6575 protected void processMouseMotionEvent(MouseEvent e) { |
6575 protected void processMouseMotionEvent(MouseEvent e) { |
6576 MouseMotionListener listener = mouseMotionListener; |
6576 MouseMotionListener listener = mouseMotionListener; |
6577 if (listener != null) { |
6577 if (listener != null) { |
6578 int id = e.getID(); |
6578 int id = e.getID(); |
6880 * invalidates the component hierarchy. |
6880 * invalidates the component hierarchy. |
6881 * |
6881 * |
6882 * @see #isDisplayable |
6882 * @see #isDisplayable |
6883 * @see #removeNotify |
6883 * @see #removeNotify |
6884 * @see #invalidate |
6884 * @see #invalidate |
6885 * @since JDK1.0 |
6885 * @since 1.0 |
6886 */ |
6886 */ |
6887 public void addNotify() { |
6887 public void addNotify() { |
6888 synchronized (getTreeLock()) { |
6888 synchronized (getTreeLock()) { |
6889 ComponentPeer peer = this.peer; |
6889 ComponentPeer peer = this.peer; |
6890 if (peer == null || peer instanceof LightweightPeer){ |
6890 if (peer == null || peer instanceof LightweightPeer){ |
6983 * this method should call <code>super.removeNotify</code> as |
6983 * this method should call <code>super.removeNotify</code> as |
6984 * the first line of the overriding method. |
6984 * the first line of the overriding method. |
6985 * |
6985 * |
6986 * @see #isDisplayable |
6986 * @see #isDisplayable |
6987 * @see #addNotify |
6987 * @see #addNotify |
6988 * @since JDK1.0 |
6988 * @since 1.0 |
6989 */ |
6989 */ |
6990 public void removeNotify() { |
6990 public void removeNotify() { |
6991 KeyboardFocusManager.clearMostRecentFocusOwner(this); |
6991 KeyboardFocusManager.clearMostRecentFocusOwner(this); |
6992 if (KeyboardFocusManager.getCurrentKeyboardFocusManager(). |
6992 if (KeyboardFocusManager.getCurrentKeyboardFocusManager(). |
6993 getPermanentFocusOwner() == this) |
6993 getPermanentFocusOwner() == this) |
7092 * owner. |
7092 * owner. |
7093 * |
7093 * |
7094 * @return <code>true</code> if this <code>Component</code> is |
7094 * @return <code>true</code> if this <code>Component</code> is |
7095 * focusable; <code>false</code> otherwise |
7095 * focusable; <code>false</code> otherwise |
7096 * @see #setFocusable |
7096 * @see #setFocusable |
7097 * @since JDK1.1 |
7097 * @since 1.1 |
7098 * @deprecated As of 1.4, replaced by <code>isFocusable()</code>. |
7098 * @deprecated As of 1.4, replaced by <code>isFocusable()</code>. |
7099 */ |
7099 */ |
7100 @Deprecated |
7100 @Deprecated |
7101 public boolean isFocusTraversable() { |
7101 public boolean isFocusTraversable() { |
7102 if (isFocusTraversableOverridden == FOCUS_TRAVERSABLE_UNKNOWN) { |
7102 if (isFocusTraversableOverridden == FOCUS_TRAVERSABLE_UNKNOWN) { |
7431 * @see java.awt.event.FocusEvent |
7431 * @see java.awt.event.FocusEvent |
7432 * @see #addFocusListener |
7432 * @see #addFocusListener |
7433 * @see #isFocusable |
7433 * @see #isFocusable |
7434 * @see #isDisplayable |
7434 * @see #isDisplayable |
7435 * @see KeyboardFocusManager#clearGlobalFocusOwner |
7435 * @see KeyboardFocusManager#clearGlobalFocusOwner |
7436 * @since JDK1.0 |
7436 * @since 1.0 |
7437 */ |
7437 */ |
7438 public void requestFocus() { |
7438 public void requestFocus() { |
7439 requestFocusHelper(false, true); |
7439 requestFocusHelper(false, true); |
7440 } |
7440 } |
7441 |
7441 |
8068 /** |
8068 /** |
8069 * Adds the specified popup menu to the component. |
8069 * Adds the specified popup menu to the component. |
8070 * @param popup the popup menu to be added to the component. |
8070 * @param popup the popup menu to be added to the component. |
8071 * @see #remove(MenuComponent) |
8071 * @see #remove(MenuComponent) |
8072 * @exception NullPointerException if {@code popup} is {@code null} |
8072 * @exception NullPointerException if {@code popup} is {@code null} |
8073 * @since JDK1.1 |
8073 * @since 1.1 |
8074 */ |
8074 */ |
8075 public void add(PopupMenu popup) { |
8075 public void add(PopupMenu popup) { |
8076 synchronized (getTreeLock()) { |
8076 synchronized (getTreeLock()) { |
8077 if (popup.parent != null) { |
8077 if (popup.parent != null) { |
8078 popup.parent.remove(popup); |
8078 popup.parent.remove(popup); |
8093 |
8093 |
8094 /** |
8094 /** |
8095 * Removes the specified popup menu from the component. |
8095 * Removes the specified popup menu from the component. |
8096 * @param popup the popup menu to be removed |
8096 * @param popup the popup menu to be removed |
8097 * @see #add(PopupMenu) |
8097 * @see #add(PopupMenu) |
8098 * @since JDK1.1 |
8098 * @since 1.1 |
8099 */ |
8099 */ |
8100 @SuppressWarnings("unchecked") |
8100 @SuppressWarnings("unchecked") |
8101 public void remove(MenuComponent popup) { |
8101 public void remove(MenuComponent popup) { |
8102 synchronized (getTreeLock()) { |
8102 synchronized (getTreeLock()) { |
8103 if (popups == null) { |
8103 if (popups == null) { |
8124 * content and format of the returned string may vary between |
8124 * content and format of the returned string may vary between |
8125 * implementations. The returned string may be empty but may not be |
8125 * implementations. The returned string may be empty but may not be |
8126 * <code>null</code>. |
8126 * <code>null</code>. |
8127 * |
8127 * |
8128 * @return a string representation of this component's state |
8128 * @return a string representation of this component's state |
8129 * @since JDK1.0 |
8129 * @since 1.0 |
8130 */ |
8130 */ |
8131 protected String paramString() { |
8131 protected String paramString() { |
8132 final String thisName = Objects.toString(getName(), ""); |
8132 final String thisName = Objects.toString(getName(), ""); |
8133 final String invalid = isValid() ? "" : ",invalid"; |
8133 final String invalid = isValid() ? "" : ",invalid"; |
8134 final String hidden = visible ? "" : ",hidden"; |
8134 final String hidden = visible ? "" : ",hidden"; |
8138 } |
8138 } |
8139 |
8139 |
8140 /** |
8140 /** |
8141 * Returns a string representation of this component and its values. |
8141 * Returns a string representation of this component and its values. |
8142 * @return a string representation of this component |
8142 * @return a string representation of this component |
8143 * @since JDK1.0 |
8143 * @since 1.0 |
8144 */ |
8144 */ |
8145 public String toString() { |
8145 public String toString() { |
8146 return getClass().getName() + '[' + paramString() + ']'; |
8146 return getClass().getName() + '[' + paramString() + ']'; |
8147 } |
8147 } |
8148 |
8148 |
8149 /** |
8149 /** |
8150 * Prints a listing of this component to the standard system output |
8150 * Prints a listing of this component to the standard system output |
8151 * stream <code>System.out</code>. |
8151 * stream <code>System.out</code>. |
8152 * @see java.lang.System#out |
8152 * @see java.lang.System#out |
8153 * @since JDK1.0 |
8153 * @since 1.0 |
8154 */ |
8154 */ |
8155 public void list() { |
8155 public void list() { |
8156 list(System.out, 0); |
8156 list(System.out, 0); |
8157 } |
8157 } |
8158 |
8158 |
8159 /** |
8159 /** |
8160 * Prints a listing of this component to the specified output |
8160 * Prints a listing of this component to the specified output |
8161 * stream. |
8161 * stream. |
8162 * @param out a print stream |
8162 * @param out a print stream |
8163 * @throws NullPointerException if {@code out} is {@code null} |
8163 * @throws NullPointerException if {@code out} is {@code null} |
8164 * @since JDK1.0 |
8164 * @since 1.0 |
8165 */ |
8165 */ |
8166 public void list(PrintStream out) { |
8166 public void list(PrintStream out) { |
8167 list(out, 0); |
8167 list(out, 0); |
8168 } |
8168 } |
8169 |
8169 |
8172 * specified print stream. |
8172 * specified print stream. |
8173 * @param out a print stream |
8173 * @param out a print stream |
8174 * @param indent number of spaces to indent |
8174 * @param indent number of spaces to indent |
8175 * @see java.io.PrintStream#println(java.lang.Object) |
8175 * @see java.io.PrintStream#println(java.lang.Object) |
8176 * @throws NullPointerException if {@code out} is {@code null} |
8176 * @throws NullPointerException if {@code out} is {@code null} |
8177 * @since JDK1.0 |
8177 * @since 1.0 |
8178 */ |
8178 */ |
8179 public void list(PrintStream out, int indent) { |
8179 public void list(PrintStream out, int indent) { |
8180 for (int i = 0 ; i < indent ; i++) { |
8180 for (int i = 0 ; i < indent ; i++) { |
8181 out.print(" "); |
8181 out.print(" "); |
8182 } |
8182 } |
8198 * the specified print writer. |
8198 * the specified print writer. |
8199 * @param out the print writer to print to |
8199 * @param out the print writer to print to |
8200 * @param indent the number of spaces to indent |
8200 * @param indent the number of spaces to indent |
8201 * @throws NullPointerException if {@code out} is {@code null} |
8201 * @throws NullPointerException if {@code out} is {@code null} |
8202 * @see java.io.PrintStream#println(java.lang.Object) |
8202 * @see java.io.PrintStream#println(java.lang.Object) |
8203 * @since JDK1.1 |
8203 * @since 1.1 |
8204 */ |
8204 */ |
8205 public void list(PrintWriter out, int indent) { |
8205 public void list(PrintWriter out, int indent) { |
8206 for (int i = 0 ; i < indent ; i++) { |
8206 for (int i = 0 ; i < indent ; i++) { |
8207 out.print(" "); |
8207 out.print(" "); |
8208 } |
8208 } |