JavaFX button with multiple text lines

I need to create a toolbar on the screen. It has multiple buttons. Each button must have multiple lines of text For example:

I checked the Internet and stackoverflow, but I couldn't find anything to show how to do this in JavaFX I'm using JavaFX 8

Can someone help me?

TKS

Solution

You can also use wraptextproperty However, you must set the toolbar height to be greater than the expected button height

Button btn = new Button();
btn.wrapTextproperty().setValue(true);
// or btn.setWrapText(true);
btn.setText("Some looooooooooooong text");

Alternatively, if you want to determine the exact location of the packaging line, you can:

Button btn = new Button();
btn.setText("Line1\n Line2\n Line3");

The last method can be done without changing the height of the toolbar

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>