3
votes

I have a TextArea anchored to the top, left and right of an AnchorPane. Whenever the window is resized to be smaller (which resizes the AnchorPane and TextArea), scroll bars will show up on the TextArea, even though the text isn't even close to filling up the whole area.

The behaviour is inconsistent, sometimes it will show both scroll bars, sometimes just horizontal, and sometimes none. You can make the scroll bars disappear by making the window bigger.

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 an issue with JavaFX? Because I can't think of anything I could have done wrong.

1

1 Answers

1
votes

You did everything right.

This is an JavaFX Issue, I think there is no way to fix that.

But you can try

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

or disable the Scrollbar if its never needed or show it the whole time.

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