Updating swing components from an arbitrary thread

Posted by / 21-Dec-2017 03:10

So AWT was designed to provide the same functionality on all platforms, yet have the appearance of a native application.

It also means that Swing components are much more flexible and can be extended and modified in your applications in ways that native components could never be.

I experienced no problems as expected since all the code will be executed in the Event Dispatch Thread (EDT).

Of course using this approach could make the game less responsive if your game logic is extensive and hogs the EDT, but given that you try to invoke your game logic every 100 millisecond I assume it can't be that extensive.

I see code like this all the time as a fix to the threading issues, am I missing something or is it really a solution?

I can't post the actual code as it's too long, so I created a simple example: import event.*; import javax.swing.*; public class Event Test extends JFrame implements Key Listener, Runnable private boolean is Key Down; public Event Test() set Size(500, 500); set Default Close Operation(JFrame.

updating swing components from an arbitrary thread-59updating swing components from an arbitrary thread-28updating swing components from an arbitrary thread-22

One thought on “updating swing components from an arbitrary thread”