0

I started learning JavaFx and I found out that there is a scene builder for Java projects but you have to make an FXML project. Can anyone explain to me the differences and if the coding between two is different? Also is it worth it to work with the scene builder? I'm using the Eclipse IDE.

Isaac Smith
  • 137
  • 9
ita07
  • 81
  • 10
  • To be honest, I found coding the GUI to be fairly straightforward. I also found the cognitive friction of going back and forth between FXML and Java code was too overbearing. – trilogy Apr 03 '19 at 02:15

2 Answers2

5

JavaFX is the graphics package that you will be using to create the GUI application.

FXML is an XML format that JavaFX can use to import certain features of your GUI. You can make these files yourself but it would be extremely time consuming, which is where SceneBuilder comes in. SceneBuilder lets you design your GUI, then makes and edits your FXML file for you as you edit your interface.

Here's an Oracle link about making a GUI with FXML without SceneBuilder.

If you're working with graphics in Java, SceneBuilder is probably beneficial to use as you can design how you want it, rather than coding and launching repeatedly.

Here's another link about making a GUI with FXML and SceneBuilder.

Isaac Smith
  • 137
  • 9
0

To elaborate a bit more on what Issac Smith's answer, basically an FXML file is a set of serialized Panes/Controls which you can plug and play with FXMLLoader in code.

You will always need a JavaFX project in order to run a JavaFX application FXML file, because an FXML file cannot run by itself.

SceneBuilder is just a tool for you to visualize/design an FXML file instead of typing them out in a text editor. Like what Issac mentioned, it's possible to create FXML without SceneBuilder, but it's going to be tedious, as you will need to place the FXML in a JavaFX project, then run the application after every change in order to see what has visually changed.

Lastly, it is also possible to create a JavaFX application without any FXML. All the controls can be instantiated and configured via code. Again, the main difference is still SceneBuilder here. Most controls from the JavaFX API are kind of made purely via codes. The main reason is because it is easier to create complex layout/rendering rules with codes.

Jai
  • 8,165
  • 2
  • 21
  • 52