views:

29

answers:

1

Swing newbie question...

I have a system where there is a large number of independent widgets in the window (think >100) getting asynchronous updates and then requesting a repaint. When these widgets get updates very very fast, they seem to overload the Swing event thread so that user interaction (e.g., right clicking to display the context menu) takes ages.

I'm sure that there is a pattern for handling this.

The few solutions I could think of are: 1) Priorities on events (doubt that's supported) 2) Writing a custom repaint manager to slow down items from my widgets. 3) Have components request a repain from another class, and that class would somehow calculate the dirty region and contact Swing.

Thanks!

+2  A: 

In Swing multiple repaint requests are combined into one if possible. For this reason I don't think that multiple repaint events are overloading your app. Is it possible that something else is done on the EDT rather then UI operations only?

P.S. You are correct that painting can be optimized by calculating the dirty region. But that is usually done by UI part of your component because only it knows how to correctly accomplish such calculation.

eugener