⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 component.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   * Repaint this entire component. The <code>update()</code> method   * on this component will be called as soon as possible.   *   * @see #update(Graphics)   * @see #repaint(long, int, int, int, int)   */  public void repaint()  {       if (isShowing())      repaint(0, 0, 0, width, height);  }  /**   * Repaint this entire component. The <code>update()</code> method on this   * component will be called in approximate the specified number of   * milliseconds.   *   * @param tm milliseconds before this component should be repainted   * @see #paint(Graphics)   * @see #repaint(long, int, int, int, int)   */  public void repaint(long tm)  {    if (isShowing())      repaint(tm, 0, 0, width, height);  }  /**   * Repaints the specified rectangular region within this component. The   * <code>update</code> method on this component will be called as soon as   * possible. The coordinates are relative to this component.   *   * @param x the X coordinate of the upper left of the region to repaint   * @param y the Y coordinate of the upper left of the region to repaint   * @param w the width of the region to repaint   * @param h the height of the region to repaint   * @see #update(Graphics)   * @see #repaint(long, int, int, int, int)   */  public void repaint(int x, int y, int w, int h)  {    if (isShowing())      repaint(0, x, y, w, h);  }  /**   * Repaints the specified rectangular region within this component. The   * <code>update</code> method on this component will be called in   * approximately the specified number of milliseconds. The coordinates   * are relative to this component.   *   * @param tm milliseconds before this component should be repainted   * @param x the X coordinate of the upper left of the region to repaint   * @param y the Y coordinate of the upper left of the region to repaint   * @param width the width of the region to repaint   * @param height the height of the region to repaint   * @see #update(Graphics)   */  public void repaint(long tm, int x, int y, int width, int height)  {    if (isShowing())      {        ComponentPeer p = peer;        if (p != null)          p.repaint(tm, x, y, width, height);      }  }  /**   * Prints this component. This method is provided so that printing can be   * done in a different manner from painting. However, the implementation   * in this class simply calls the <code>paint()</code> method.   *   * @param g the graphics context of the print device   *    * @see #paint(Graphics)   */  public void print(Graphics g)  {    paint(g);  }  /**   * Prints this component, including all sub-components. This method is   * provided so that printing can be done in a different manner from   * painting. However, the implementation in this class simply calls the   * <code>paintAll()</code> method.   *   * @param g the graphics context of the print device   *    * @see #paintAll(Graphics)   */  public void printAll(Graphics g)  {    paintAll(g);  }  /**   * Called when an image has changed so that this component is repainted.   * This incrementally draws an image as more bits are available, when   * possible. Incremental drawing is enabled if the system property   * <code>awt.image.incrementalDraw</code> is not present or is true, in which   * case the redraw rate is set to 100ms or the value of the system property   * <code>awt.image.redrawrate</code>.   *   * <p>The coordinate system used depends on the particular flags.   *   * @param img the image that has been updated   * @param flags tlags as specified in <code>ImageObserver</code>   * @param x the X coordinate   * @param y the Y coordinate   * @param w the width   * @param h the height   * @return false if the image is completely loaded, loading has been   * aborted, or an error has occurred.  true if more updates are   * required.   * @see ImageObserver   * @see Graphics#drawImage(Image, int, int, Color, ImageObserver)   * @see Graphics#drawImage(Image, int, int, ImageObserver)   * @see Graphics#drawImage(Image, int, int, int, int, Color, ImageObserver)   * @see Graphics#drawImage(Image, int, int, int, int, ImageObserver)   * @see ImageObserver#imageUpdate(Image, int, int, int, int, int)   */  public boolean imageUpdate(Image img, int flags, int x, int y, int w, int h)  {    if ((flags & (FRAMEBITS | ALLBITS)) != 0)      repaint();    else if ((flags & SOMEBITS) != 0)      {	if (incrementalDraw)	  {	    if (redrawRate != null)	      {		long tm = redrawRate.longValue();		if (tm < 0)		  tm = 0;                repaint(tm);	      }	    else              repaint(100);	  }      }    return (flags & (ALLBITS | ABORT | ERROR)) == 0;  }  /**   * Creates an image from the specified producer.   *   * @param producer the image procedure to create the image from   * @return the resulting image   */  public Image createImage(ImageProducer producer)  {    // Sun allows producer to be null.    if (peer != null)      return peer.createImage(producer);    else      return getToolkit().createImage(producer);  }  /**   * Creates an image with the specified width and height for use in   * double buffering. Headless environments do not support images.   *   * @param width the width of the image   * @param height the height of the image   * @return the requested image, or null if it is not supported   */  public Image createImage (int width, int height)  {    Image returnValue = null;    if (!GraphicsEnvironment.isHeadless ())      {	if (isLightweight () && parent != null)	  returnValue = parent.createImage (width, height);	else if (peer != null)	  returnValue = peer.createImage (width, height);      }    return returnValue;  }  /**   * Creates an image with the specified width and height for use in   * double buffering. Headless environments do not support images.   *   * @param width the width of the image   * @param height the height of the image   * @return the requested image, or null if it is not supported   * @since 1.4   */  public VolatileImage createVolatileImage(int width, int height)  {    if (GraphicsEnvironment.isHeadless())      return null;    GraphicsConfiguration config = getGraphicsConfiguration();    return config == null ? null      : config.createCompatibleVolatileImage(width, height);  }  /**   * Creates an image with the specified width and height for use in   * double buffering. Headless environments do not support images. The image   * will support the specified capabilities.   *   * @param width the width of the image   * @param height the height of the image   * @param caps the requested capabilities   * @return the requested image, or null if it is not supported   * @throws AWTException if a buffer with the capabilities cannot be created   * @since 1.4   */  public VolatileImage createVolatileImage(int width, int height,                                           ImageCapabilities caps)    throws AWTException  {    if (GraphicsEnvironment.isHeadless())      return null;    GraphicsConfiguration config = getGraphicsConfiguration();    return config == null ? null      : config.createCompatibleVolatileImage(width, height, caps);  }  /**   * Prepares the specified image for rendering on this component.   *   * @param image the image to prepare for rendering   * @param observer the observer to notify of image preparation status   * @return true if the image is already fully prepared   * @throws NullPointerException if image is null   */  public boolean prepareImage(Image image, ImageObserver observer)  {    return prepareImage(image, image.getWidth(observer),                        image.getHeight(observer), observer);  }  /**   * Prepares the specified image for rendering on this component at the   * specified scaled width and height   *   * @param image the image to prepare for rendering   * @param width the scaled width of the image   * @param height the scaled height of the image   * @param observer the observer to notify of image preparation status   * @return true if the image is already fully prepared   */  public boolean prepareImage(Image image, int width, int height,                              ImageObserver observer)  {    if (peer != null)	return peer.prepareImage(image, width, height, observer);    else	return getToolkit().prepareImage(image, width, height, observer);  }  /**   * Returns the status of the loading of the specified image. The value   * returned will be those flags defined in <code>ImageObserver</code>.   *   * @param image the image to check on   * @param observer the observer to notify of image loading progress   * @return the image observer flags indicating the status of the load   * @see #prepareImage(Image, int, int, ImageObserver)   * @see Toolkit#checkImage(Image, int, int, ImageObserver)   * @throws NullPointerException if image is null   */  public int checkImage(Image image, ImageObserver observer)  {    return checkImage(image, -1, -1, observer);  }  /**   * Returns the status of the loading of the specified image. The value   * returned will be those flags defined in <code>ImageObserver</code>.   *   * @param image the image to check on   * @param width the scaled image width   * @param height the scaled image height   * @param observer the observer to notify of image loading progress   * @return the image observer flags indicating the status of the load   * @see #prepareImage(Image, int, int, ImageObserver)   * @see Toolkit#checkImage(Image, int, int, ImageObserver)   */  public int checkImage(Image image, int width, int height,                        ImageObserver observer)  {    if (peer != null)      return peer.checkImage(image, width, height, observer);    return getToolkit().checkImage(image, width, height, observer);  }  /**   * Sets whether paint messages delivered by the operating system should be   * ignored. This does not affect messages from AWT, except for those   * triggered by OS messages. Setting this to true can allow faster   * performance in full-screen mode or page-flipping.   *   * @param ignoreRepaint the new setting for ignoring repaint events   * @see #getIgnoreRepaint()   * @see BufferStrategy   * @see GraphicsDevice#setFullScreenWindow(Window)   * @since 1.4   */  public void setIgnoreRepaint(boolean ignoreRepaint)  {    this.ignoreRepaint = ignoreRepaint;  }  /**   * Test whether paint events from the operating system are ignored.   *   * @return the status of ignoring paint events   * @see #setIgnoreRepaint(boolean)   * @since 1.4   */  public boolean getIgnoreRepaint()  {    return ignoreRepaint;  }  /**   * Tests whether or not the specified point is contained within this   * component. Coordinates are relative to this component.   *   * @param x the X coordinate of the point to test   * @param y the Y coordinate of the point to test   * @return true if the point is within this component   * @see #getComponentAt(int, int)   */  public boolean contains(int x, int y)  {    return inside (x, y);  }  /**   * Tests whether or not the specified point is contained within this   * component. Coordinates are relative to this component.   *   * @param x the X coordinate of the point to test   * @param y the Y coordinate of the point to test   * @return true if the point is within this component   * @deprecated use {@link #contains(int, int)} instead   */  public boolean inside(int x, int y)  {    return x >= 0 && y >= 0 && x < width && y < height;  }  /**   * Tests whether or not the specified point is contained within this   * component. Coordinates are relative to this component.   *   * @param p the point to test   * @return true if the point is within this component   * @throws NullPointerException if p is null   * @see #getComponentAt(Point)   * @since 1.1   */  public boolean contains(Point p)  {    return contains (p.x, p.y);  }  /**   * Returns the component occupying the position (x,y). This will either   * be this component, an immediate child component, or <code>null</code>   * if neither of the first two occupies the specified location.   *   * @param x the X coordinate to search for components at   * @param y the Y coordinate to search for components at   * @return the component at the specified location, or null   * @see #contains(int, int)   */  public Component getComponentAt(int x, int y)  {    return locate (x, y);  }  /**   * Returns the component occupying the position (x,y). This will either   * be this component, an immediate child component, or <code>null</code>   * if neither of the first two occupies the specified location.   *   * @param x the X coordinate to search for components at   * @param y the Y coordinate to search for components at   * @return the component at the specified location, or null   * @deprecated use {@link #getComponentAt(int, int)} instead   */  public Component locate(int x, int y)  {    return contains (x, y) ? this : null;  }  /**   * Returns the component occupying the position (x,y). This will either   * be this component, an immediate child component, or <code>null</code>   * if neither of the first two occupies the specified location.   *   * @param p the point to search for components at   * @return the component at the specified location, or null   * @throws NullPointerException if p is null   * @see #contains(Point)   * @since 1.1   */  public Component getComponentAt(Point p)  {    return getComponentAt (p.x, p.y);  }  /**   * AWT 1.0 event delivery.   *   * Deliver an AWT 1.0 event to this Component.  This method simply   * calls {@link #postEvent}.   *   * @param e the event to deliver   * @deprecated use {@link #dispatchEvent (AWTEvent)} instead   */  public void deliverEvent (Event e)  {    postEvent (e);  }  /**   * Forwards AWT events to processEvent() if:<ul>   * <li>Events have been enabled for this type of event via   * <code>enableEvents()</code></li>,   * <li>There is at least one registered listener for this type of event</li>   * </ul>   *   * @param e the event to dispatch   */  public final void dispatchEvent(AWTEvent e)  {    // Some subclasses in the AWT package need to override this behavior,    // hence the use of dispatchEventImpl().    dispatchEventImpl(e);  }  /**   * AWT 1.0 event handler.   *   * This method simply calls handleEvent and returns the result.   *   * @param e the event to handle   * @return true if the event was handled, false otherwise   * @deprecated use {@link #dispatchEvent(AWTEvent)} instead   */  public boolean postEvent (Event e)  {    boolean handled = handleEvent (e);    if (!handled && getParent() != null)      // FIXME: need to translate event coordinates to parent's      // coordinate space.      handled = getParent ().postEvent (e);    return handled;  }  /**   * Adds the specified listener to this component. This is harmless if the   * listener is null, but if the listener has already been registered, it   * will now be registered twice.   *   * @param listener the new listener to add   * @see ComponentEvent   * @se

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -