×

Discussion Board

Results 1 to 4 of 4

Hybrid View

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    10

    repaint() does not clear the screen!

    Hello,

    i'm using this.repaint(); to make the screen get updated, but unfortunately old drawings will not be cleared - how can i refresh my screen if an object was moved so that the old object will deleted?

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    repaint() doesn't clear the screen, if you want to clear the screen before repainting you have to add a fillRect() in the beginning of the paint() method to clear the screen for you.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    2
    Never it is mentionned in any Java API that repaint() clears the screen or any rendering surface attached to a Graphics object. It will simply trigger a call to paint() with a Graphics object being clipped to cover at least that area.
    The best thing to do is to paint a uniform background first then paint other sutff, and not paint anything that's not supposed to show.

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    4
    repaint() method also do the same as paint() method. For drawing moving objects is the best make "buffer", image which has the same width and height as display. Than use a getGraphics() to get a graphics interface to draw on background. It can be used to graw images, texts, rects or lines in (for example) drawBg() method. This method You can call only in cause of changing background. In paint() method simply draw "buffer" image and on this image draw cursor ( or any else stuff which will move). I hope this is undestandable, my english is not up too much ;o)

Posting Permissions

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