0

I'm writing a program in Java GUI. I have a main JFrame from which released with SQL queries buttons and also a JFrame with gif. For SQL queries, I've created a class that provides connection to the database and has a method for each type of query. The fact is that while doing the query, the new JFrame with gif freezes. I know that is because the query is not a Thread. But inherit from Thread is not the solution at all.

I want every method of consultation is like a Thread. To also be able to launch it from anywhere in the main JFrame JFrame without any freezing.

Thank you very much.

Aditya
  • 1,334
  • 1
  • 12
  • 23
York Xtrem
  • 58
  • 1
  • 10

2 Answers2

1

Since your application is using swing you should take a look at the SwingWorker class that is designed just for jobs like that.

While you're about it take your time to study the swing threading model, e.g. starting from here.

piet.t
  • 11,718
  • 21
  • 43
  • 52
0

Solution: Use SwingWorker - DoInBackground () Make check here. - Done () Ask here showing a JTable.

York Xtrem
  • 58
  • 1
  • 10