13

I downloaded the JavaFx source code from http://hg.openjdk.java.net/openjfx/2.2/master/rt/summary.

The name of the folder in the zip file is re-e71070b0e0c0.

I unzipped this and added the folder under Project Structure - Global Libraries in Idea, however it doesn't work. When I try to open a class it just shows field names and /* compiled code */. I couldn't find anything in the manual.

2

3 Answers 3

19

Update Oct 2025

Creating a JavaFX Project in Idea using Maven

I recommend using the Idea new JavaFX project wizard to create a Maven project.

The created project an be customized to add additional JavaFX components as needed as instructed in Basil's answer and this answer for adding JavaFX WebView support.

Syncing Source and Documentation with the IDE

Once that is done, Idea's Maven integration can download and associate the source and documentation for JavaFX with the JavaFX version your are using. The association can be done automatically. Or you can manually synchronize the documentation and source using a dropdown in the Maven Panel in Idea.

Sync Sources

Navigating to Source

To view the source of a JavaFX class or method, hover over a JavaFX method or class name in your source file with a mouse and (on a Mac) press the ⌘ Command key. The highlight (navigate to source) key will be different on other systems like Linux or Windows. The class or method name will highlight with a blue underlined hyperlink you can click to navigate to the source for the given JavaFX class or method.

Using other Build Tools

This can also work when other build tools such as Gradle are used, however I don't use those most of the time, so don't have specific advice on that.

While sources and documentation can be manually attached in the IDE without using a build tool such as Maven or Gradle, I recommend using a build tool synchronized with the IDE rather than relying solely on the IDE's built in build system and manual configuration of dependencies and sources. An example of manually attaching sources and documentation for Java and JavaFX is in the answer to: Source files for Liberica's JavaFX.


Prior Updates and Answers

Much of the information in this answer is now outdated.

More up-to-date information on using JavaFX with Java 11+ in IntelliJ Idea, is available at:

  • openjfx.io in the section titled: "JavaFX and IntelliJ".

Though, the above-linked article is more focused on using JavaFX in IntelliJ rather than viewing JavaFX library source code in IntelliJ.


These instructions are only necessary for the JavaFX 2.x branch and will be obsoleted once JDK 8 is released.

After you have downloaded the source zip and extracted it, open Idea and follow these instructions:

  1. Modify the source structure for your 1.7 SDK:

    File | Project Structure | SDKs | Sourcepath

For each sub-project in the extracted zip, type Alt+Insert and add the respective source directory. For example rt-e71070b0e0c0\javafx-ui-charts\src, rt-e71070b0e0c0\javafx-ui-common\src, etc. Not all JavaFX 2.x source code is currently open sourced, so this will only add the open sourced portions.

  1. Set the documentation lookup path:

    File | Project Structure | SDKs | Documentation Paths

Specify a url Alt+S for the documentation: http://docs.oracle.com/javafx/2/api/

  1. In your JavaFX application source, place your cursor over a JavaFX class usage, for instance LineChart:

  2. Press Ctrl+B to open the source code file LineChart.java from your downloaded zip.

  3. Press Shift+F1 to open documentation on the LineChart in a browser.

  4. Press Ctrl+Q to get quick access to documentation from in the IDE.

Update Oct 16 2013

JDK 8 now includes JavaFX source files.

To tell Idea where JavaFX sources are:

  1. Modify the source structure for your 1.8 SDK:

    File | Project Structure | SDKs | Sourcepath

Press Alt+S to add the file javafx-src.zip, which is located in the root directory of the JDK 8 distribution.

  1. Set the documentation lookup path:

    File | Project Structure | SDKs | Documentation Paths

Specify a url Alt+S for the documentation: http://download.java.net/jdk8/jfxdocs.

The JDK 8 JavaFX documentation url will likely change when JDK 8 reaches General Availability release stage.

Step 3 above provides keyboard shortcuts to quickly access the JavaFX sources and documentation from your project.

Sign up to request clarification or add additional context in comments.

2 Comments

The linked article didn't help me. I still don't understand how to view JavaFX sources, most crucially javadocs, in IntelliJ
Yep, the answer had became outdated over time. I added a further update with advice on how to associate JavaFX sources and documentation with an Idea project by using the Idea New JavaFX Project Wizard, Maven build tool, and Idea's Maven project integration features.
4

(Since this is one of the Google hits for "javafx source code", I'll dump this anwer here too):

Quoting from this answer: For Java 8, the source of the public parts of JavaFX are actually laying right along in the JDK installation as a sibling of src.zip: javafx-src.zip - on the root of your normal JDK Java 8 installation.

Eclipse doesn't by default link them up when you add the JRE (or it finds it itself) - obviously a bug - so you'll have to do that yourself, by hitting Preferences -> Installed JREs. Find your JDK 8, hit Edit button. On the list JRE system libraries, expand the jfxrt.jar node, and link in the javafx-src.zip file.

Comments

1

I've faced this problem on Ubuntu 16.04 with JavaFX 8 (open-jfx package). The fix was to install the missing source package:

sudo apt install openjfx-source

IntellJ started showing JavaFX source code the second after the command finished executing.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.