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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top