Reputation: 1167
I have a Label
in a Scene
. I need to get always the largest font size for the text in it, so that the text always takes the maximum size in the available size of the label.
How can I do that?
Upvotes: 7
Views: 31631
Reputation: 1320
I am not sure if we have a way to set font size according to the size of the container. But you could scale the text vertically or horizontally to fit the container bounds. Check out the following ...
Scaling a textbox without truncating text within it
Upvotes: 2
Reputation: 8900
final double MAX_FONT_SIZE = 30.0; // define max font size you need
label.setFont(new Font(MAX_FONT_SIZE)); // set to Label
Upvotes: 10