Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

animation problem

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Those are the largest trousers in the world! Especially when next to this ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic