Results 1 to 2 of 2

Thread: paint() vs repaint() vs update() ???

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Posts
    4

    Question paint() vs repaint() vs update() ???

    Could somebody please explain what are the differences among these three graphical methods? I am getting really confused by them.

    - paint(Graphics g)
    - repaint(Graphics g)
    - update(Graphics g)

    When do I need them? Where do I use them? How do I use them? What differences do I have to concern with when applying them in an application and in an applet?

  2. #2
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    I'm not sure about update(), but the repaint() method you usually use when you want to run the paint()-method, which means redraw the component.
    And also, repaint() doesn't want a Graphics object as parameter.

    And according to the API:
    "
    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.
    "
    the update() method seems to do more or less that work too. Anyone more certain about this?

    You could check out Suns article about painting: http://java.sun.com/products/jfc/tsc...ing/index.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width