JavaFX Button with multiple text lines

前端 未结 6 2082
一个人的身影
一个人的身影 2021-01-13 04:35

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:

6条回答
  •  余生分开走
    2021-01-13 05:30

    From sobolev's response, you can do:

    Button btn = new Button();
    btn.setText("Line1\n Line2\n Line3");
    button.textAlignmentProperty().set(TextAlignment.CENTER);
    

    This will create 3 lines of text and allign them in the center of your button.

提交回复
热议问题