What’s the difference between fx:id and id: in JavaFX?

id you use to set a CSS ID to your Component, for example <Text id="welcome-text" .../> and in your stylesheet you have something like #welcome-text { font-size: 16pt; } so this will be applied to your Text.

fx:id you use if you want to work with your Components in your Controller class, where you annotate them with @FXML Text myWelcomeText.

Leave a Comment