I have a GUI with some TextArea elements to display information. As the GUI shall react to keyevents I added a EventHandler to the scene element. Because I didn't want to add one EventHandler to each textarea I disabled them to prevent that they are focused because then the scene's eventhandler doesn't work anymore. Now I have the problem the text is displayed in gray and not in black anymore eventhough I changed that in the css file. Do you have any ideas why the text isn't black and how i could fix that?
Here is some code:
private val scene =
new Scene {
stylesheets.add("css/style.css")
onKeyTyped = (new EventHandler[KeyEvent] {
def handle(event: KeyEvent) {
...
}
})
...
}
private val description = new TextArea{
text = "some text"
wrapText = true
disable = true
styleClass.add("txtarea")
maxHeight = 400
}
.txtarea:disabled{
-fx-font-size: 18pt;
-fx-text-fill: #000000;
-fx-prompt-text-fill: #000000;
-fx-opacity: 1.0;
-fx-background-color: white;
}
You also need to provide style for the scroll pane embedded in the TextArea:
.txtarea .scroll-pane:disabled{
-fx-opacity: 1.0;
}