I am working on a java application which has a login form in a jframe. I have text fields and buttons in it. 

The login button has an eventlistener which is an **inner-class** of the class that creates the login window. When user presses the login button, the listener takes the values form the fields and passes it to a validator which validates it using a mysql database and returns true and false based on the input by user. Now based on the return value the listener updates the ui using the `if-else` statement. This whole thing is working is fine.

The problem is that when the validation is being carried out the gui cannot be used, because every thing is being done with a single thread. So for that time the `gui` is kind of freezed.
How can I use multithreading to avoid this problem and use other gui components while validation is carried out.