This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Ok, so I'm trying to have an actionListener that, when triggered, creates a dialog with a progress bar. Seems like this would be a pretty common thing to do - you hit a button, a popup comes up saying 'Loading...' or whatever while it's processing something. But here's the problem - the progress bar never appears. The dialog comes up, but it's empty. I've spent a couple hours looking at this and have figured out that the problem definitely arises from putting the code inside the actionListener. I'm assuming it has something to do it being run as a separate thread, but I'm not sure what to do about it...
I've diluted the code I'm working on down and posted it below...and it's basically is a heavily modified version of this example.
Also probably worth noting that if I comment out dlg.setVisible(false) [line 39], the progress bar will appear after the rest of the listener completes, but at that point you can't do anything since it's a modal dialog (as it should be).
Anyone have any ideas how to make this work, or a better way of doing this? I mean I suppose I could have the dialog be static class member and just turn it on and off as needed, but that seems a strange way of doing it and not quite ideal for my project.