Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Working with a progress bar

 
paul a carron
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm creating a small application that restarts services(see post Edit method to accept parameters for details). One thing I'd like to add is a progress bar.

I created it in SceneBuilder and have declared and called it in my class. The issue I'm having is with getting it to run when something happens. For example, I'd like it to run when the stop button is clicked. In theory it could run for the duration of the buttonStop() method. Is this possible and if so, how do I do it? I'm fairly sure I need to use bind() or addListener() in some way but am struggling beyond that.

Here's my class so far(please ignore the combo box options and the fact that everything is done on the Spooler. This is just for testing purposes):



Oh, one other thing. Is it possible to set the progress bar to only be visible when it is running?

Thanks
Paul
 
Knute Snortum
Sheriff
Posts: 3320
84
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you want the progress bar to progress as the program is waiting for the service to stop.  I'm not sure this is the best use of a progress bar.  Perhaps a ProgressIndicator would be better.  You can read about both here.

I think the basic steps would be for you to set the ProgressIndicator to visible, start a task that stops the service, and then set the indicator to done when the task returns.
 
paul a carron
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Knute. I was thinking about it earlier and tend to agree with you. I'll have to give it a go later though.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!