department education consolidating private loans - Updating swing components from an arbitrary thread

by  |  19-Oct-2017 19:06

It turns out that, with the help of a few special tricks, we can eat our cake and have it.Before reading further, I recommend you to look through a great official introduction to Painting in AWT and Swing so you can refresh your knowledge of the basics and understand what I’m going to explain next more easily.

updating swing components from an arbitrary thread-57updating swing components from an arbitrary thread-31updating swing components from an arbitrary thread-70

In this article I enumerate reasons why typical approach to painting in AWT / Swing can result in substantial visual lags, provide examples that demonstrate the problem and propose methods to significantly reduce the drawing latency.

Despite the focus on Java platform, the key ideas can be extended to most modern operation systems and GUI frameworks.

What happens when a new painting request is issued before a previous one is handled?

For example, let’s generate 10 painting requests with 50 ms interval, but spend 100 ms on each painting: The scope of processing delay is not necessarily limited by the drawing method, any activity in EDT counts.

Demo: Region To control the extension of “dirty” regions, we can assign a dedicated repaint manager to our component (but only in Swing, not in AWT).

Community Discussion