I display an animated gif file in my application, but it seems it is much slower than the origional.Why? my application implement Runnable interface and create a new thread in the application for displaying the animated gif file (the animated GIF is also moving). also when I want to display a moving object, sometime it doesn't show up until the middle of the screen (say, i want to move the picture from left to right on the screen). Thanks a lot.
In AWT and Swing, it's the GUI thread that executes the calls to paint(). Every applet and application that has a GUI, has a GUI thread, which spontaneously calls paint() whenever all or part of a component needs redrawing. When you call repaint(), you are issuing a request to the GUI thread that it should perform the painting routines. GUI thread does it in a reasonable time scale, although this might be limited by other high-priority threads. Calling repaint() in your methods, compared with directly calling paint(), avoids the problem of unsyncronization in drawing but introduces possible omission of part of the drawing process. When calling paint(), you have to do the drawing one by one. If the drawing is time-consuming and updates are frequent, the drawing would get further and further behind where it should be. So, with obvious trade-off, you make the decision according to specific needs.
" Veni, vidi, vici "<br />" I came, I saw, I conquered "
Those are the largest trousers in the world! Especially when next to this ad: