I need to create a toolbar in my screen that will have multiple buttons, and each button must have multiple lines of Text. For example:
I looked over the internet and StackOverflow but I couldn't find anything showing how to do this in JavaFX. I'm using JavaFX 8.
Someone could help me, please?
Tks
I resolved this problem including a VBox inside my button, and then including several Labels inside the VBox. Like this:
The result is:
If there is a more elegant way to have the same result, please, let me know. Thank you.
My solution is pretty much the same as the one given by the OP, but instead of
Label
usesText
so it's more flexible to changes in the size of the button, as it will use as many lines as needed. If required, also one can set a wrapping width, to define a width constraint.Also you can use the
wrapTextProperty
. But you have to set toolbar height greater than expected button height.Or if you want to determine exactly where the line should be wrapped, you can go this way:
Last way will work without changing toolbar height.
From sobolev's response, you can do:
This will create 3 lines of text and allign them in the center of your button.
In the button text property select "switch to multi-line mode
"