• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

JAVA FX Multi Threaded UI

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm looking for a general strategy or approach as opposed to a solution for a specific code problem, kind of a "look at this class" or "you want to use this approach" kind of answer.

I'm frustrated in not being able to have multiple independently operating UI elements in FX. As a simple example, I can put a counter (textbox with a timeline that updates it counting as fast as it can), and it works fine just sitting there. But as soon as I start to do other things in the UI, it interrupts my counter causing it to stall/pause momentarily.

How can I have a timer (let alone sophisticated animated charts or something) that continue to update seamlessly and independently of anything else going on in the UI?

Thanks!
 
Saloon Keeper
Posts: 12878
279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't perform long running operations on the JavaFX application thread. Regular use of UI components should not really affect the counter. If an event handler does more than just update the user interface quickly, let it do the heavy lifting in a background task.

Use javafx.concurrent.Task or javafx.concurrent.Service to perform long running tasks in the background. A task can fire its own events to notify the application thread of updates to the state of the background task.
 
Ken Matson
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that strategy, but even just typing at a good pace in a text area will cause my counter to "sputter" (split second pauses).
 
Stephan van Hulst
Saloon Keeper
Posts: 12878
279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post an SSCCE that demonstrates the issue?
 
Water proof donuts! Eat them while reading this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic