3

In swing we have:

boolean SwingUtilities.isEventDispatchThread()

that returns true if it is called from swing event dispatch thread.

is there anything similar in javafx?

AgostinoX
  • 7,477
  • 20
  • 77
  • 137

1 Answers1

6

Yes you can check that you are in the FX thread with:

Platform.isFxApplicationThread();

Note that many UI interacting methods will throw an exception when called outside the FX thread.

assylias
  • 321,522
  • 82
  • 660
  • 783
  • +1 for the reference to the docs. I'm studying fx threading to get to this question http://stackoverflow.com/questions/12318861/javafx-2-catching-all-runtime-exceptions. I am really uncomfortable with the answers provided there, that mean that in fx you can't even log runtime excepions because you are not able to catch them . Can you give a little help to that question too? :-) – AgostinoX Oct 08 '12 at 22:06