Apparently JavaFX is getting really into the game now as far as I see and I think its time I start getting to know it .. Just read a couple of articles and a few questions came up in my mind:
- Do I need to use IDE (eclipse) for javafx projects or text editor?
- If I have already existing project can I add the GUI afterwards as I'd do with swing after the logic is working?
- Any articles/tutorials are more than welcome if you know any

Thanks in advance!

Dani AI

Generated

Short, practical primer that builds on what and said:

IDE vs editor — an IDE is not required, but it speeds up real work with JavaFX (FXML editing, Scene Builder integration, run configurations). Scene Builder is a supported, drag-and-drop designer (standalone or IDE-integrated) and is the fastest way to get comfortable with FXML before hand-coding layouts. (gluonhq.com)

Packaging and dependencies — modern JavaFX (post–JDK 11) is distributed separately as OpenJFX modules. For any Java >= 11 you should add the OpenJFX modules via your build tool (Maven/Gradle) or use a JDK distribution that bundles JavaFX; Java 11 removed JavaFX from the JDK, so manual dependency management is required for newer JDKs. Use the OpenJFX docs and the JavaFX Maven/Gradle plugins rather than copying jars by hand. (oracle.com)

How to structure work (practical workflow) — implement and unit-test core logic first, expose state with JavaFX Properties (SimpleStringProperty, etc.), and keep controllers thin so UI glue is just binding code. Prefer property binding over manual listener plumbing; it makes UI updates declarative and easier to test. A typical one-line binding looks like:

label.textProperty().bind(model.nameProperty());

This follows 's point about properties/binding. (docs.oracle.com)

Quick checklist / troubleshooting

  • Start with a small FXML + Controller sample from a JavaFX archetype (use the OpenJFX samples).
  • Use Maven/Gradle with org.openjfx artifacts to avoid manual native libs.
  • If FXML fails to load, verify resource paths and that the controller is on the classpath (module-info vs classpath issues are a common trap).
  • Keep UI logic out of model tests; test business code without launching JavaFX.

This approach keeps the learning curve manageable: Scene Builder and FXML to prototype, Properties/binding for clean UI-model integration, and modern build plugins for repeatable deploys.

Recommended Answers

All 9 Replies

You don't need an IDE, but if you are going to use one NetBeans seems to have integrated it better. JavaFX comes with a drag'n'drop GUI builder called SceneBuilder that you can use stand-alone or in your IDE.

Yes, you can (probably should!) add the GUI to the logic layer rather than v.v. However, compared to Swing you have a properties and binding mechanism based on Observables that your logic layer can (should?) implement to provide GUI support, rather than Swing's addListener(...) approach.

I've played with it, no real projects yet, and there's a significant learning "hump" to get over if you're coming from Swing. I'm yet to be convinced that it offers any real advantage over Swing for ordinary business-type GUIs. However, for more graphic animated consumer-oriented work it's miles ahead.

DoogleDude123 has been getting into JavaFX, so I'm sure he can contribute a lot to this discussion.

commented: banana +10

Great answer James, I ll keep it unsolved and maybe get some more inputs by other users for a few days, Thanks!

Hey Slavi, glad to see some interest in Java FX. I definitely think Java FX is excelling now and will soon become a primary over swing.

If you're looking into getting into it, I would suggest building a simple GUI Program (Anything you want), inside of the SceneBuilder (What JC was talking about), and adding a Controller Class to the GUI to do program the logic. You can grab SceneBuilder from the JDK 8 Extra Downloads page.

Use an FXMLLoader to load your GUI.
FXMLLoader loader = new FXMLLoader(MainClass.class.getResource("path/to/fxml/gui.fxml"));

For programming the controller, don't forget to set the fx:id under the code menu on the right side in SceneBuilder, and then go ahead and grab the Sample Controller Skeleton from View > Show Sample Controller Skeleton. Make sure full is checked then just copy-paste that into an empty class file.

Link your new Controller by calling it in loader.setController(new GUIControllerClass());

Of course this isn't all you need, google around for diferent things, like a basic tutorial, this should be a good start however. Come back if you have questions.

commented: Excellent input. Thansk you. +15

ps Forgot to mention media support. At last we can bury the old Java media framework in the dungheap of history where it belongs. I use FX's MP3 player even in Swing apps because (a) it's trivially easy and (b) it works...

    static MediaPlayer withFile(File file) {  // factory method
        // force JFX environment initialisation if necessary...
        // API doc for javafx.embed.swing.JFXPanel constructor says: 
        // Implementation note: when the first JFXPanel object is created, 
        // it implicitly initializes the JavaFX runtime. 
        // This is the preferred way to initialize JavaFX in Swing.
        new javafx.embed.swing.JFXPanel();
        // now we need a string representation of the URI of our media...
        String source = file.toURI().toString();
        // ... to create a Media object and a player to play it
        return new MediaPlayer(new Media(source));
    }

    // Control the MediaPlayer with play(), pause(), stop(), dispose()
    // query media metadata etc - see API doc for MediaPlayer and Media

Great, thanks guys!
@Doogle, do you use IDE (if so which?) or text editor? I am considering to get netBeans just for these apps, might be a bit hard to begin straight on editor

-For future interested in javaFX readers, I found people recomending this

That tutorial looks good, but surely if anyone is learning JavaFX now they should be using the Java 8 version of it. There are very significant improvements, eg Properties, that change how you use JavaFX.

Does Luna eclipse come without JavaFX inbuilt? :o

Hmm this is really weird, had Luna installed but it didn't have plugins for it however, if you get it from Click Here
It comes with inbuilt things?

Eclipse works fine :P I have since switched to IntelliJ IDEA community edition. It doesn't matter what you use for it. Update your JDK to Java 8, JavaFX is built in now.

Stick with the SceneBuilder for a while, then program your own GUI through code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.