Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
49 views
in Technique[技术] by (71.8m points)

java - What's the difference between fx:id and id: in JavaFX?

Maybe a really newbie's question....

I'm starting learning JavaFX in a FMXL Application using the Scene Builder, by reading this tutorials:

http://docs.oracle.com/javase/8/javafx/get-started-tutorial/fxml_tutorial.htm

So once i applied some changes, an issue with this 2 IDs came up... I might have missed or confused something about them...

Can anyone tell me in which cases they are used one or another?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...