Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Modal Wait-Dialog in FX?  RSS feed

 
Mario Schwaiger
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm pretty new to JavaFX and would like to establish a waiting window (modal) for an operation which is going to consume more time.

Strangely, when I use the code like that the window only opens AFTER:



Other Variants like are ending up the same way and just using some text-information like are having the same result: They give the information after the operation was finished.

Doing some research made me switch to a thread instead, coming up with this and the class LongOperation o, which implements Runnable.



Haven't really worked with threads for a while and seems mixing it with FX is not something I understand too much of :/
Help is highly appreciated, thank you
 
Knute Snortum
Sheriff
Posts: 3833
91
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't done this much either, but I have successfully implemented a progress bar while the task was working.

I think the trick is to get your thread off of the main JavaFX thread.  Working with threads directly is not recommended as there are many library classes that can help you.  I used a javafx.concurrent.Task because I had a return value, but maybe you don't need this.

Have you read the Oracle documentation for concurrency?  It's de rigueur for the topic.

This is how I implemented the progress meter.  It don't all apply to your situation, but maybe you can glean something from it.  If you want to see the context, it on this GitHub page, in the class ScrabbleWords
 
Mario Schwaiger
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help!

Made my program run =)

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!