JavaFX / ScalaFX - Change text color of disabled TextArea?


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 {
    onKeyTyped = (new EventHandler[KeyEvent] {
      def handle(event: KeyEvent) {

private val description = new TextArea{    
  text = "some text"
  wrapText = true
  disable = true 
  maxHeight = 400

  -fx-font-size: 18pt;
  -fx-text-fill: #000000;
  -fx-prompt-text-fill: #000000;
  -fx-opacity: 1.0;
  -fx-background-color: white;  
2/6/2013 9:55:10 AM

Accepted Answer

You also need to provide style for the scroll pane embedded in the TextArea:

.txtarea .scroll-pane:disabled{
  -fx-opacity: 1.0;
2/22/2013 7:25:57 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow