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.

2
  • This should be a good start: stackoverflow.com/questions/1531073/… Commented Mar 14, 2014 at 12:45
  • I understand what the connection pool. But that does not solve my problem. thanks Commented Mar 14, 2014 at 12:51

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I will look: swing threading model and SwingWorker. Let's see if I find solution.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.