It is likely that recognizer.recognize()
is a blocking method, that is, until it is finished, it will not return.
What this means is until the method returns, you are blocking the Event Dispatching Thread, which is responsible for, amongst other things, process paint requests.
This means until your method returns, nothing can be painted or updated (or responded to).
A simple solution would be to use a SwinWorker
, which would allow you to set up a background process in order to perform the blocking call but also provides a number of methods synchronise any updates to the UI via the EDT
Take a closer look at Concurrency in Swing and SwimgWorker for more details