Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 480
John Kyle Avatar asked May 25 '18 18:05

John Kyle


1 Answers

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>
like image 75
JackCody Avatar answered Oct 18 '22 07:10

JackCody