Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


[java] Mouse Pointer

This topic is 6198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The application i''ve realized is a simple panel displaying a scrolling image. Permormance are very good but when the mouse passes over the scrolling panel speed massively goes down. I think the mouse pointer forces the panel to repaint itself some times more slowing all down . Are good solutions? thanks.

Share this post

Link to post
Share on other sites
If you''re continuously animating on a Component, then you can pretty much ignore the repaint calls from the operating system (By the time you get the call from the OS you''ve either already repainted or are preparing to). If you''re using Java 1.4 then a simple call to Component.setIgnoreRepaint(true) will stop the OS from delivering repaint calls (but the internal AWT still will, so your calls to repaint() will still work).
If you''re working in 1.3 or lower, you''ve got to roll your own solution. Consider:
import java.awt.*;
class AnimComponent extends Component
public AnimComponent () { }
// Empty update function, stops calls to repaint()

// from getting forwarded to paint(), make

// it final so no one else re-defines it

public final void update (Graphics g) { }
// Our own repaint function, skips the AWT repaint()

// and update() functions and goes straight to paint()

public void animRepaint ()
Graphics g = getGraphics();
if (g != null)

It''s a simple example, but it should work. You''ll still get the
overhead of the AWT dispatching repaint events, but you stop responding to them. It will make your inner loop a little faster, however, because you stop forcing the re-draw of every frame to be called by the AWT Event Dispatch Thread (if you were calling repaint(), that is).

"So crucify the ego, before it''s far too late. To leave behind this place so negative and blind and cynical, and you will come to find that we are all one mind. Capable of all that''s imagined and all conceivable."
- Tool

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!