JavaFX: classes vs. fxml

Question:

If you google the JavaFX Tutorial, the search engine will return a bunch of lessons on how to program in JavaFX. But almost in all the program is written at the expense of classes. But you can still use fxml, isn't that better? What are the pros and cons of each approach?

Answer:

Less code in the controller is the only plus. For instance:

<ComboBox fx:id="url" layoutX="397.0" layoutY="62.0" onAction="#startCombo" prefHeight="25.0" prefWidth="149.0">
              <items>
                  <FXCollections fx:factory="observableArrayList">
                      <String fx:value="http://wwww.site.com" />
                      <String fx:value="http://wwww.site.com/" />
                      <String fx:value="http://wwww.site.com" />
                      <String fx:value="http://wwww.site.com" />
                      <String fx:value="http://wwww.site.com" />
                      <String fx:value="http://wwww.site.com" />
                  </FXCollections>
              </items>
          </ComboBox>

it's all in fxml, actually there is no difference, write as you want

Scroll to Top