Note: these steps assume that you are using the latest JDK version (17).
In the project browser, right click on the project name and create a file named build.gradle:

Write a build script. Here is a template for JavaFX applications:
plugins { id "application" // Use Application plugin id "org.openjfx.javafxplugin" version "0.0.9" // Use JavaFX plugin } mainClassName = "my.package.Application" // Set this to your main class repositories { mavenCentral() } javafx { version = "16" // JavaFX Version modules = [ "javafx.controls" ] // JavaFX modules. Add them to this array. }
Once you have finished, import the project:

This may take a while depending on your internet speed.
You may have to adjust runtime configurations to use Gradle, but that shouldn't be necessary.
You may encounter the following error:
BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 61
If that is the case, install Gradle CLI (if you haven't already), and open a command prompt/terminal in the project folder.
Run the following command (works on Windows/Mac/Linux):
gradle wrapper --gradle-version=7.3 --distribution-type=bin
Once you have done that, reload the Gradle project.
I could not resist another GIF:

You may also need to rearrange the source folders:

I apologise for the cat photo, but it was just a placeholder image. I definitely didn't specifically choose it.