The Artima Developer Community
Sponsored Link

Java Answers Forum
JProgressBar not rendering in time

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Gibran Shah

Posts: 27
Nickname: gibby
Registered: Jun, 2004

JProgressBar not rendering in time Posted: Nov 5, 2004 5:19 PM
Reply to this message Reply
Advertisement
Hello,

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?

Gib

Topic: Get rid of that comma in my JSpinner!!! Previous Topic   Next Topic Topic: How to access JSpinner's JTextField?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use