Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+5 votes

what is the difference between Text and Label method in javafx? Are they pretty much the same thing?

asked in CSC305 Fall 2019 by (1 point)

2 Answers

0 votes

The only difference that I know between Text and Label methods, is that Label can be modified to have different backgrounds, graphics, and alignments, which text does not have.

answered by (1 point)
0 votes

Label and Text have different CSS properties. Label inherits from Labeled, Control, and Region, which means it inherits a great many "styleable" properties which Text doesn't have. A Label can have alignment, a graphic, a background, a border, a displayed keyboard mnemonic, built-in wrapping, and can be intelligently clipped with an ellipsis ("…").

Text can participate in a TextFlow. (Technically, Label can also, but it is treated as just another embedded control and is not laid out as text.)

In general, if you want to show the purpose of an input control by placing one or more words next to it, and/or you want to allow direct keyboard navigation to an input control, you use a Label. If you want to display text content not associated with input, you use Text.

answered by (1 point)
...