John Kyle
John Kyle

Reputation: 125

JavaFX TextFlow ScrollBar

I am creating small project in JavaFX. I created a TextFlow field to show messages i chat.

It looks good but,

enter image description here

When I add more messages this field does not make ScrollBar like TextArea.

enter image description here

I set max height in SceneBuilder but it does not work.

Is there way to create automatic ScrollBar like in TextArea ?

Upvotes: 6

Views: 3860

Answers (1)

JackCody
JackCody

Reputation: 115

it may some one comes here and looking for answer after one year of posting that question

the answer is

try to use Scene Builder the one that come with Netbeans just googl it and draw first TextFlow then click right and warp it with ScrollPane

or you can paste this code on you FXML

  <ScrollPane fx:id="sp" layoutX="1.0" layoutY="1.0" prefHeight="189.0" prefViewportHeight="148.0" prefViewportWidth="139.0" prefWidth="288.0" AnchorPane.bottomAnchor="66.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0">
     <content>

              <TextFlow fx:id="pan1" prefHeight="193.0" prefWidth="276.0">


     </content>
  </ScrollPane>

Upvotes: 7

Related Questions