Low Priority redraws

hey all,

I've got an audio app with lots of things that change constantly during playback. I've found that sometimes it can be hard to use the GUI because the swing thread is busy redrawing the meters over and over again as new data comes in asynchronously rather than the rest of the GUI. For example, the user might push a button which causes a new window to open and the window opens but nothing is drawn in it for a long time. I am using the repaint() method and java 1.4.

I've found that creating a queue in a low priority thread to handle these repaints seems to help, but the code is rather convoluted, even if it is only a hundred lines or so. Is this a common problem? Is there a better way? Animation apps must have to deal with this problem, so maybe I'm missing something.

thanks for the help!

[834 byte] By [bjornbjorna] at [2007-10-3 4:05:09]
# 1

> the user might push a button which causes a new window to open

> and the window opens but nothing is drawn in it for a long time. I am

> using the repaint() method and java 1.4.

1) Sounds to me like you have a loop somewhere.

2) Don't know what your animation is like but maybe you should be using a BufferedImage and just redrawing the image rather that creating it from scratch all the time.

3) When I do animation I find its better to use a single Timer to animate multiple components rather then using multiple Timers to animate a single component.

You question is too generic to give any specific advice. We have no idea how your meters work how frequently the data changes....

camickra at 2007-7-14 22:04:24 > top of Java-index,Desktop,Core GUI APIs...