title: Asynchronous UI update with Swing
body: <p>I've written a Scala program that I'd like to be triggered through a UI (also in Swing). The problem is, when I trigger it, the UI hangs until the background program completes. I got to thinking  that the only way to get around this is by having the program run in another thread/actor and have it update the UI as and when required. Updating would include a status bar which would show the file currently being processed and a progressbar.</p>
  
  <p>Since Scala actors are deprecated, I'm having a tough time trying to plough through Akka to get some kind of basic multithreading running. The examples given on the Akka website are also quite complicated.</p>
  
  <p>But more than that, I'm finding it difficult to wrap my head around how to attempt this problem. What I can come up with is:</p>
  
  <ol>
  <li>Background program runs as one actor</li>
  <li>UI is the main program</li>
  <li>Have another actor that tells the UI to update something</li>
  </ol>
  
  <p>Step 3 is what is confounding me. How do I tell the UI without locking up some variable somewhere?</p>
  
  <p>Also, I'm sure this problem has been solved earlier. Any sample code for the same would be highly appreciated.</p>