Frage

Currently, my entire gui has to freeze while the database connection is established. So instead, I wanted to run the connection in a background thread/task, and then tell the user when the connection has been established.

Should I use a SwingWorker or a normal Thread or something else of the kind?

War es hilfreich?

Lösung

Should I use a SwingWorker or a normal Thread or something else of the kind?

SwingWorker would be the optimal way, since it ensures that updates to the GUI are performed on the Event Dispatch Thread. Having said that, it is also possible to use a Thread, just so long as you ensure the GUI is updated on the EDT.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top