• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Show a running circle while waiting and not block the whole app

 
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let the user continue working while waiting for a long running database operation to return the dataset
How do I display the "running circle" while that operation is executing?
I want the user to be able to tab to other JavaFX tabpanes and work on something else.
 
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you find any tutorials about progress bars? If you are using FX, then this tutorial won't help you a lot.

Not a beginning topic: moving to our databases and FX fora.
 
Ranch Hand
Posts: 127
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The keyword here is "decoupling" and failing to do it correctly is a common beginner issue wich lead to your mentioned "locking up of the whole application".
It comes down to how GUIs in Java work (keyword "EDT" - Event Dispatch Thread) and that beginners often not correctly understand why they need to run their code in a different thread than where the event is triggert.
Just by experience I guess your code looks a bit like this: You have some listener wich reacts to some event triggert by some button or alike and then, as the query takes time, your application becomes unresponsive. That's because you most likely locking up the EDT wich needs to always run clean by itself to keep the UI responsive. Care must also be taken when you want to update your GUI after your task has finished: You have to re-inject anything modifying the GUI back into the EDT. In Swing this is done with SwingUtilities.invokeLater(). FX should have something similar.
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I remember correctly, a call to Application#launch() starts the corresponding th‍read in FX. You are liable to find FX applications crash with exceptions if you try to run anything on the wrong thre‍ad.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The method you're looking for is called Platform.runLater().  Give me a second and I'll find some example code, or you can google javafx platform.runlater.
 
Knute Snortum
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
AhFai Chan
Ranch Hand
Posts: 271
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, these hints are like Aurum for me
 
He got surgery to replace his foot with a pig. He said it was because of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic