How to resize a button depending on the text in JavaFX?

This might be a trivial question, but I wasn't able to find a solution so far.
If you create a button with a longer word as text, lets say 'Überspringen'(the german word for Skip), JavaFx will automatically truncate the Text to 'Übersprin'+EllipsisString.
Button skipButton = new Button("\u00dcberspringen");
enter image description here

Is there an easy solution to avoid the truncation? I just could hardcode a new size, but in Swing the button-size was adjusted automatically.

I already tried setWrapText(true) but that didn't work, I think because there is no whitespace.



Read more here: https://stackoverflow.com/questions/67935641/how-to-resize-a-button-depending-on-the-text-in-javafx

Content Attribution

This content was originally published by toni at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: