How to import the javafx library

Hi!

Im new to both javafx and Processing, and im building a Processing program where I want to create a GUI using javafx.

In the program im creating a new thread that is the javafx Application, but Processing is giving me the error:

"Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder."

I have tried to install the fx-Library in the Processing/Libraries folder, but nothing i do seems to work.

I also tried to various import lines (import javafx.application.Application;)

Answers

  • I have same question.

  • Solution - find the location of jxfrt.jar, by following what's on this StackOverflow post - whats-the-location-of-the-javafx-runtime-jar-file-jfxrt-jar.
    Then, inside your libraries folder (of sketchbook), create new folder jxfrt, and inside it, another folder library. Inside this inner folder, put the earlier jar file, and reload Processing. Done!

  • It'd be much easier for us if the PDE was setup to recognize "jxfrt.jar" already. [-(
    Processing already uses it for its renderer FX2D, but we can't access those dependencies! ~X(

  • Exactly! That's what I don't like.
    Even now I'm not sure it will work, just hoping. Trying it out now.

  • Alright, this just got stranger - it gives an error,

    No library found for javafx.stage.FileChooser

    But I'm pretty sure it exists, as I extracted and looked inside the jar file.

  • @GoToLoop Which thread exactly is the event thread?? I also get an error -

    java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = AWT-EventQueue-0

  • Alright, so it means that I must call such functions only inside draw.

    All JavaFX functions to be called only inside draw.

  • Alright, everything solved.
    If someone wants, please delete all the nonsense I've written, leaving the first and second comments.

  • Alright, everything solved.

    Do you plan to share the solution?

  • @quark Um, okay.
    It's effectively the same as my first comment, just ignore the warnings Processing gives you, and always call JavaFX functions inside draw() or such (mediocre/advanced users will understand, others probably shouldn't be reading this).

Sign In or Register to comment.