dcsimg
When scrolling a browser over an applet displaying an image, the applet flashes
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Derek_Cooper
Posted On:   Wednesday, July 24, 2002 12:04 PM

When I scroll over my applet, the image I am displaying flashes as I scroll. I realize the applet is simply repainting itself over and over again, however it looks horrible and occassionally the image may not be displayed properly when a user stops scrolling. Are there any tricks to prevent this effect, or will I just have to sit tight and suffer? I feel like I have tried every possible manipulation of the painting architecture, but I am hoping someone can enlighten me.



Thanks!

Re: When scrolling a browser over an applet displaying an image, the applet flashes

Posted By:   Prashanth_Sukumaran  
Posted On:   Wednesday, July 24, 2002 12:23 PM

Did you try Buffering



Looks like you are overriding the paint or update method




Try this way






Dimension dimension = getSize();
int i = dimension.width;
int j = dimension.height;
theImage = createImage(i, j);
if(theImage != null)
gBuffer = theImage.getGraphics();



You can do things like


gBuffer.setColor(colbg);

gBuffer.setFont(new java.awt.Font("Dialog", Font.PLAIN, 9));

gBuffer.fillRect(0, 0, i, j);

gBuffer.drawImage(theImage, 0, 0, this);

gBuffer.drawLine(0, 0, 0, j - 1);

gBuffer.draw3DRect(1, 1, i - 3, j - 3, true);



in the end you do


g.drawImage(theImage, 0, 0, this);



Hope this helps



Prashanth Sukumaran
About | Sitemap | Contact