Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Graphics

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay I've got questions about Graphics and will probably have more coming as I learn more about graphics. Well currently I was told to do all of my graphics painting in paint(Graphics g). So I create this:



That's for keylistener and calling repaint to change the position of the image. This is for paint(Graphics g).



Now it works, but how do I get rid of the afterimage? And am I doing everything right?

And this is cool. I didn't know this site supported UBB Code otherwise I would've used the code tags in my last topic.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you're doing everything right. To get rid of the previous contents of the screen, erase them by drawing the background color over them.

Your next question will be "how do I get rid of the flickering?" and we get to talk about double-buffering, and possibly offscreen graphics contexts...

But we've got a forum dedicated to graphics (AWT/Swing/JFace/SWT), so please ask these next questions over there!
 
Jonathan Sternberg
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh sorry, I'll do that then.

And my teacher showed me today how to get rid of the afterimage too and it was really simple. I don't think I'm creating anything complicated enough to need double buffering, yet.
 
reply
    Bookmark Topic Watch Topic
  • New Topic