JavaFX TextArea scrollbar shows on resize even if not needed

I have a TextArea anchored to the vertex, left and right of the AnchorPane. Whenever the window is resized smaller (which changes the size of the AnchorPane and TextArea), scrollbars will appear on the TextArea, even though the text isn't even close to filling the entire area.

The behavior is inconsistent, sometimes it shows as scrollbars, sometimes just horizontal and sometimes nothing. You can make the scrollbars smaller by making the window larger.

Here is the FXML for the TextArea:

<TextArea fx:id="teamDescription" layoutX="10.0" layoutY="107.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onKeyPressed="#handleTextAreaKeyPress" prefHeight="42.0" prefWidth="380.0">
    <VBox.margin>
        <Insets bottom="10.0" />
    </VBox.margin>
</TextArea>

      

Is this a problem with JavaFX? Because I can't think of anything that I could have done wrong.

+3


source to share


1 answer


You did everything right.

This is a JavaFX problem, I think there is no way to fix it.

But you can try



true https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ScrollPane.html#setFitToHeight-boolean-

or disable the scrollbar if you never needed it or showed it all the time.

https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/ScrollPane.html#setHbarPolicy-javafx.scene.control.ScrollPane.ScrollBarPolicy-

+1


source







All Articles