Just a quickie about how to tell Eclipse to attach the JavaFX sources for an improved development experience.
When you’re using Eclipse with a JDK as your system library, the IDE will helpfully display Javadoc when you hover over members of official Java classes and let you jump into the code whenever you want to. This is extremely helpful to get to know the classes and take a look at their inner workings.
This is possible because the JDK comes with its own sources and Eclipse knows about them. It attaches those sources to the compiled classes from the JDK and thus provides you those benefits.
For reasons unknown to me, Eclipse does not automatically do this for the JavaFX classes (from the package javafx ), though. But because like the rest of the JRE, the FX sources are also bundled with the JDK, few things are easier than to attach them.
- open preferences (Window ~> Preferences)
- edit the used JRE (Java ~> Installed JREs ~> Select JDK on the right ~> Edit)
- start to attach FX sources (select jfxrt.jar ~> Source Attachement)
- configure the sources (select External location ~> External File)
- select the sources bundled with the JDK
(go to JDK root folder, e.g. C:/Program Files/Java/jdk1.8.0_20
~> select javafx-src.zip)
- almost done, just OK/Finish your way back…
To verify that this worked, open the Open Type dialog (by default with Ctrl-Shift-T) and check that you can open types from JavaFX like javafx.application.Application, javafx.application.Platform or javafx.beans.property.Property.
You should also be able to see tooltips like this one:
You have seen a step by step guide how to attach the JavaFX sources in Eclipse so it shows the Javadoc and lets you jump into the source code.
Last step: Have even more fun with JavaFX!