• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Don't Refresh Screen On Repaint(s)

 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like my applet continue to display the current canvas when I repaint().
Does a way to do this exist?
Thank You in Advance for Your Help,
Lou
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, why in the world would you want to do this ??? Repainting is all taken care of by the JDK ... so, if you wanted it to just stay the same (assuming it is all manually painted), why not just neglect to call repaint() or whatever method it is that usually forces the canvas to repaint .. ?
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some things I want to add or change on the current screen.
Say I have 10 items on the screen, I want to move two and have the rest remain where they are.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's how you do it:
Don't draw onto the screen, but instead draw into an offscreen graphics buffer. When it comes time to draw to the screen, copy the offscreen buffer to the screen.
Now whatever changes you make to the offscreen buffer can be used to refresh the screen without remembering what those changes were.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest,
I looked for a GraphicsBuffer class, did not find one.
Are you suggesting that I instantiate a second Graphics object where the draw methods are used and then copied to the displayed Graphics object prior to repaint()?
Thanks,
Lou
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, You get one from an Image. See, for example, the GraphLayout demo in the JDK demos/applets directory.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,
An example would be great!
But I"m not finding a "JDK demos/applets directory".
Can you help me get there?
Thank You for All Your Help,
Lou
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you install the JDK on Windows, you get asked if you want to install some demos; if you don't have a "demos" subdirectory on your machine, you must've said no. They're workth looking at. You could reinstall the JDK and say "yes" this time.
 
Lou Pelagalli
Ranch Hand
Posts: 150
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,
Looks like I tipped my hand.
I've been doing java for about three months. When I read "JDK demos/applets directory", I thought some link inside javaranch.com.
In fact I have two JDK demos/applets directories
C:\Java\j2sdk1.4.2_01\demo\applets
C:\Java\j2sdk1.4.2_01\demo\plugin\applets
Thanks,
Lou
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic