Search code examples
javaintellij-ideajavafxfxmlscenebuilder

Convert/import existing javafx project into SceneBuilder


I have a javafx project already in Intellij but doing the view/gui stuff is just kinda tedious. I found scenebuilder and would like to use it for my existing project, but dont know how to "import" it. I understood that I need fxml files, but dont know where to create them etc. Can anyone help me? Thanks!


Solution

  • Update

    For an example of creating a custom component library and importing it into SceneBuilder (with sample code and screenshots) see:


    Create your FXML files and edit them in SceneBuilder.

    As James_D notes in comments:

    There's no tool I know of for converting Java-based UI to FXML. You would just have to re-do all the view in FXML one way or another if you want to use SceneBuilder.

    You can also edit the FXML text directly in your IDE for small simple changes, but, in general for large projects with a lot of FXML files, it will probably be better to do most of the editing or at least the initial FXML creation using SceneBuilder.

    Search the web for a good tutorial on FXML if you need one.

    As you are using Idea, to get started use the JavaFX new project wizard and slowly copy in, then port over parts of your existing application from your existing project as you replace the view logic.

    Idea (or at least some recent version of it that I have tried) does have the ability to use SceneBuilder embedded in the IDE, though I have found that functionality is a bit flaky, so I don't advise using that at this time.

    However, you can also configure the IDE to link to and use an external SceneBuilder installation, which works fine. Follow the instructions at:

    Stand-alone SceneBuilder is available for free from Gluon:

    Use a build tool like maven, following the maven standard directory layout for file placement.

    Follow the standards and conventions for resource lookup outlined in the:

    You don't need to fully convert all view logic from Java code to FXML, you can have an application which mixes the two paradigms and that can work well, just choose what works best for your application components.