Is the Swing repaint() method still safe to use outside the EDT in Java 7+?

This is the official reference: Swing’s Threading Policy In general Swing is not thread safe. All Swing components and related classes, unless otherwise documented, must be accessed on the event dispatching thread. And the repaint method does not “document otherwise”. To doubly reassure you that you do not need to look any further than an … Read more

Why does setSelected on JCheckBox lose effect?

It is a known bug as acknowledged by Oracle Bug ID:6924233 The JOptionPane apparently causes another event to be generated with a check box value = false. The recommended fix is to instantiate the JOptionPane using invokeLater. Submitted On 09-MAR-2010 The change is in the BasicButtonListener – Method focusLost() In 1.6.0_18 it is … ButtonModel … Read more

Prevent Swing GUI locking up during a background task

The problem is, your long running task is blocking the Thread that keeps the GUI responsive. What you will need to do is put the long running task on another thread. Some common ways of doing this are using Timers or a SwingWorker. The Java tutorials have lots of information regarding these things in their … Read more

What does SwingUtilities.invokeLater do? [duplicate]

As other answers have said, it executes your Runnable on the AWT event-dispatching thread. But why would you want to do that? Because the Swing data structures aren’t thread-safe, so to provide programmers with an easily-achievable way of preventing concurrent access to them, the Swing designers laid down the rule that all code that accesses … Read more

Java Event-Dispatching Thread explanation

The event dispatch thread is a special thread that is managed by AWT. Basically, it is a thread that runs in an infinite loop, processing events. The java.awt.EventQueue.invokeLater and javax.swing.SwingUtilities.invokeLater methods are a way to provide code that will run on the event queue. Writing a UI framework that is safe in a multithreading environment … Read more

tech