'How to make scrollbar in JavaFX TextArea work? [closed]
I declare the following TextArea in my FXML code, as direct child of an AnchorPane.
<TextArea fx:id="questionArea" layoutX="14.0" layoutY="49.0" prefHeight="300.0" prefWidth="600.0" promptText="Deze textarea bevat de vraag en de vier antwoorden." text="" wrapText="true" editable="false"/>
In my controller I add text to this (non editable) TextArea, which sometimes exceeds its height. In those cases a scrollbar shows up as expected, but it isn't working!
Does anyone know how to make the scrollbar work appropriately?
Solution 1:[1]
Setting the promptText attribute when editable="false" seems odd, and the promptText by itself doesn't enable scrolling. As an alternative, for a similar effect, set the text attribute and specify a gray text-fill paint:
<TextArea … editable="false" style="-fx-text-fill: gray"
text="Deze textarea bevat de vraag en de vier antwoorden."/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | trashgod |

