JProgressBar not rendering in time
I've got a problem with a JProgressBar. Actually it seems more like a problem with the JFrame that it's found in. The problem is it won't actually render until the task for which it reflects progress is done completely. The task in question is a really complex GUI which must go through a lot of computation in the constructor in order to arrange and display its components properly. So because of the long wait, I'm using a progress bar to allow the user to see its progress. The progress bar is one of two components in a simple little JFrame, the other is just a JLabel saying what's being done and to wait. At various points throughout the constructor of the complex GUI, I'm calling "PF.setValue(++progress);" (PF = ProgressFrame, which in turn calls setValue() for the progress bar). I believe I've initialized it correctly (JProgressBar(0, max) where max is exactly the number of times setValue() will be called), and set the initial value to 0 immediately after creating the progress bar. But throughout the whole process of the complex GUI's constructor, nothing appears in the ProgressFrame, not even the JLabel (the JFrame itself shows up but nothing in it). At the end of the complex GUI's constructor, PF.dispose() is called and it seems like it reaches this point before anything is rendered. I've tried it without the complex GUI (initialized PF and kept calling PF.setValue(i) in a monstrous for loop) and this seemed to work fine, but I did notice that it took a little while for the ProgressFrame to render (i got up to about 4000 before it did). This indicates to me that calling setVisible(true), which is the last line in the ProgressFrame's constructor, most likely places a rendering event into a queue and it waits there for an indefinite amount of time. If this is the case, how can I tell it to render immediately. If not, why won't it render right away?
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center