Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Using Swing

Ángel Serrano edited this page Apr 3, 2014 · 1 revision

Although ideally the swing code will be restricted to the minimum, care must be taken to follow the Swing rules, particularly in relation to the Swing concurrency. As a summary, only few Swing methods can be used outside the Event Dispatcher Thread (EDT) requiring that most of the interaction (even when the UI is created) must be done in the EDT.

In order to facilitate this process Swing provides an utility class SwingUtilities that provides the mechanisms (invokeAndWait and invokeLater) to facilitate the interaction with the EDT. However this utility class lacks of a simple to use mechanism to use Swing methods that return some kind of value (e.g. JComponent getX(), getY(), getWidth(), etc.). We have created a SwingEDTUtils that includes additional methods to facilitate interact with swing methods that return values.

Clone this wiki locally