Updating swing components from an arbitrary thread

Rated 4.40/5 based on 589 customer reviews

A software application normally consists of multiple threads and a single GUI data structure.This means GUI is a shared data structure and some synchronization is needed to ensure that only one thread accesses it at a time.Though AWT and Swing expose the (thread unsafe) methods to create and access the GUI components and these methods are visible to all application threads, likewise in other GUI frameworks, only a single, Event Dispatching thread has the right to execute these methods. Access to the GUI is serialized and other threads may submit some code to be executed in the EDT through a EDT message queue.That is, likewise in other GUI frameworks, the Event Dispatching Thread spends its life pumping messages: it maintains a message queue of actions to be performed over GUI.Each tutorial is fairly self-contained; but we'll also build two complete applications step by step along the way, so you can choose either to work through the whole course or to dip in and out.

This thread will be then launched by the event handler.

How to cause something to happen in one component in response to something that happens in another component.

In this tutorial we look at setting a listener on your custom component and we begin to look at MVC (Model-View-Controller) architecture.

How to improve a basic custom "listener" by using interfaces to eliminate tight coupling between your components.

Timeline scenarios in the Trident animation library allow combining multiple timeline scenario actors in a parallel, sequential or custom order.

Leave a Reply