Issue
I would like to integrate a JavaFX GUI in an existing IntelliJ IDEA Java project (java version 1.8.0_20).
Although I can create a JavaFX project from scratch (JavaFX plugin is enabled) in my IDE, I can't figure out how to create a module.
Do I need to define a new module SDK for a new Java module? Or does the type of the JavaFX module has to be IntelliJ Platform Plugin? I tried both without any success. Please help.
Many thanks, Cristina
Solution
Update for Idea 2021.3
The previous information on this answer for Idea 13.1 is now outdated.
For Idea 2021.3, create a new JavaFX project using an Idea wizard:
-
From the main menu, select File | New | Project.
In the New Project wizard, select JavaFX from the list on the left.
I advise you follow the detailed instructions for creation and execution of JavaFX project at the new JavaFX project wizard link supplied.
A new JavaFX project created this way will be different from creating a new Java project using the same wizard. The new JavaFX project will be configured to use a build tool (e.g. maven or gradle). It will have the JavaFX module dependencies defined and will include sample code for a modular HelloWorld JavaFX FXML application. It is the perfect thing to use to get started with a new JavaFX application IMO.
If you want a new Idea module rather than a new project, then you just follow the same steps as above, but instead of selecting File | New | Project, you select File | New | Module, then select JavaFX from the list on the left as before.
Alternatively, you can create new modules in Idea by defining the modules in a Maven or Gradle project and importing the build tool project file for the project into Idea.
Prior answer for Idea 13.1
I don't think you can define a new JavaFX module in Idea 13.1. Note that there is not much difference between a JavaFX project and a non-JavaFX project in Idea, so you can just create a normal Java module and make a couple of manual tweaks to the module configuration and it should behave the same as if you created a JavaFX project. See the following answer for more details:
Answered By - jewelsea
Answer Checked By - Clifford M. (JavaFixing Volunteer)