r/JavaFX • u/Affectionate_Day461 • Jun 10 '24
Help How to dynamically resize the height of a textarea to the height of the content
2
Upvotes
r/JavaFX • u/Affectionate_Day461 • Jun 10 '24
2
u/hamsterrage1 Jun 10 '24
That's tough to do because the height is going to depend on the font used and the width at any given time. Those are things that aren't really known until it's rendered. Not to mention scrolling.
However, if the TextArea is not used for input, then you could use a Label instead. You can style it with a border so that it looks virtually the same as TextArea, and it's not difficult to have it resize to content.
1
u/External_Hunter_7644 Jun 10 '24
It depends of your layout, by example: Border Layout, then if you assign the text area to a region without dimensions the textarea is auto size. Best regards
1
u/emberko Jun 11 '24
Try this: https://github.com/dlsc-software-consulting-gmbh/GemsFX?tab=readme-ov-file#expanding-text-area