Swing change text of JLabel inside ActionListener

36 Views Asked by At

When a button is clicked, it should download certain files, and every time it downloads one, it should update a JLabel to something like "downloading... 2/5". It does not do this, and the frame does not change until the ActionListener is finished.

Based on what I've researched, it seems like the problem is with the event dispatch thread, and the setText requests are queued somewhere without being executed. Is this true? How can I fix this?

1

There are 1 best solutions below

0
esteve On BEST ANSWER

You should learn about Threads (Specific tutorial for Java https://www.tutorialspoint.com/java/java_multithreading.htm)