paint(),repaint(),update()

来源:互联网 发布:方维直播源码下载 编辑:程序博客网 时间:2024/05/14 21:28
public void paint(Graphics g) Paints this component. This method is called when the contents of the component should be painted; such as when the component is first being shown or is damaged and in need of repair. The clip rectangle in the Graphics parameter is set to the area which needs to be painted. Subclasses of Component that override this method need not call super.paint(g). For performance reasons, Components with zero width or height aren't considered to need painting when they are first shown, and also aren't considered to need repair. public void repaint() Repaints this component. If this component is a lightweight component, this method causes a call to this component's paint method as soon as possible. Otherwise, this method causes a call to this component's update method as soon as possible. public void update(Graphics g) Updates this component. If this component is not a lightweight component, the AWT calls the update method in response to a call to repaint. You can assume that the background is not cleared. The updatemethod of Component calls this component's paint method to redraw this component. This method is commonly overridden by subclasses which need to do additional work in response to a call to repaint. Subclasses of Component that override this method should either call super.update(g), or call paint directly. The origin of the graphics context, its (0, 0) coordinate point, is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.