aspose file tools
The moose likes Applets and the fly likes Flickering Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Applets
Reply Bookmark "Flickering" Watch "Flickering" New topic
Author

Flickering

Sharada Kumaran
Greenhorn

Joined: May 23, 2001
Posts: 29
I have an applet which draws strings in a scrolling fashion, and draws images. How can I minimise flickering?
To display the moving text , I use Thread.sleep(). After each sleep interval, I draw the line[x] at (position-1), so that each line is moving up the applet.
Can changing the sleep interval, or the position (ie. make it position - 2), eliminate flickering, or is there a better way of doing this? I can't use update(), because each time the screen must be painted fresh, or the text would overlap.
Would appreciate a speedy response.


Sharon
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Override the update method to the following:



This should stop the flickering, but it may leave "artifacts" of what you were painting on the screen. You have to use double-buffering to overcome this problem. To find out how to use double-buffering, do a search in either this forum or the AWT/JFC/Swing forum for the word "double-buffering" or the words "double" and "buffering". I am sure you will find many posts on this topic that will show you exactly what to do.

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Flickering
 
Similar Threads
Data structure help
Swing Application Flickering?
JTextField scrolling question?
Image filter & AWT
Problem with selection in JTable