Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JProgressBar is shown after data retrival

 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am trying to add JProgressBar to the GUI so that when the user clicks on search button the JProgressBar is shown in an decorated JFrame (close, min, max buttons are not added). the class that is responsible for showing this JFrame implements Runnable, and everything related to creating the JProgressBar panel and showing the JFrame is done in run().

now here is what is happening, when I click on Search button I start the thread but it is not shown until data are retired and shown in the JTable.
I am starting the thread in the ActionListener of the search button.

may be I am doing things the wrong way (of course, otherwise why wouldn't show the progress bar !) any suggestion ?
thanks
 
Anne Crace
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am thinking this might be overkill to use a JProgressBar for this project. There isn't that much data to retrieve. Mine populates immediately. Progress bars are usually used for actions that could take several seconds to complete, which should not be the case for this project. Just my opinion.
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with you mostly, data retrieval doesn't take long. Yet I think it doesn't harm to consider the situation where you have the server serving many threads or a slow connection.

what is weird in the code that i wrote is that even whether the JFrame that shows the JProgressBar is a different thread or not the same happens ... data are retrieved and populated then the progress bar shows!!
 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I should have checked the Swing forums before posting this topic.
Anyway here is a post that helped me solving the problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic