I'm learning JavaFX in an FXML application using the Scene Builder, by reading the tutorial at oracle.com.
Once I applied some changes, an issue with these two IDs came up. I might have missed or confused something about them.
Can anyone tell me in which cases to use fx:id
and when to use id
?
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
.