konstantin
konstantin

Reputation: 893

Buttons in javafx

I have created a scene in javafx which contains three buttons. I have add in those buttons my label. the size of my label is quite small. My problem is that the text of the label is quite big and it does not fit in one line. How can I enable to expand the text in a second line inside my button? My interface currently looks like:

enter image description here

Upvotes: 0

Views: 504

Answers (3)

Ajay Sreeram
Ajay Sreeram

Reputation: 171

use

btn.wrapTextProperty().setValue(true);

or if you have specified position to break use \n

Upvotes: 0

Mazen Embaby
Mazen Embaby

Reputation: 1361

1- By coding

Button btn = new Button ("can wrap that text") ;
btn.wrapTextProperty().setValue(true)

2- By FXML scene builder under the properties of button check the wrap text

<Button mnemonicParsing="false" prefHeight="50.0" prefWidth="300.0"  text="Can wrap that text" wrapText="true"/>

Upvotes: 1

Stugal
Stugal

Reputation: 880

You can either place \n in text in place where you want to brake the line or call setWrapText(true) on your buttons.

Upvotes: 5

Related Questions