2

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,165
  • 18
  • 75
  • 126

1 Answers1

5

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
  • 310,138
  • 72
  • 642
  • 762
  • +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