• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Flickering in JApplet

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on an applet derived from JApplet class. When running the applet in browser and scrolling the page in any direction, the applet flickers. Is there a way of getting rid of this annoying behavior?
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well that might be because the paint method is being called every time and basically it goes like this
paint() is called
update() is called by default it clears the screen
and then paint() is called again to redraw the screen
what u can do is override update() so that the screen is not cleared and let paint handle everything
-manav
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another way to handle that is to have your own local buffer image and draw on that first, then draw the image onto the graphics object passed in by the system.
code example:
/* These are your buffers */
Image buffer;
Graphics bufferGraphics;
public void paint(Graphics g)
{
Dimension d = getSize();
if (buffer == null)
{
buffer = createImage(d.width, d.height);
bufferGraphics = buffer.getGraphics();
}
bufferGraphics.drawLine(0, 0, 100, 100);
g.drawImage(buffer, 0, 0, this);
}
You can also use the bufferGraphics in other methods according to your needs.

Originally posted by Sergei Voropay:
I'm working on an applet derived from JApplet class. When running the applet in browser and scrolling the page in any direction, the applet flickers. Is there a way of getting rid of this annoying behavior?


 
I'm gonna teach you a lesson! Start by looking at this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic