javafxjavafx-cssjavafx-textarea

Where can I find a complete official reference on JavaFX CSS?


When I want to change the background colour of my TextArea in JavaFX (with CSS), many people recommend "-fx-control-inner-background". But when I look up the Oracle's CSS reference there's no such a thing as "-fx-control-inner-background"! In fact nowhere, in the Internet I could find a reference on that and yet it works!

My question is where do these people discover this information? Why, for example, isn't -fx-background-color working instead?


Solution

  • I finally found out something useful that shifts my understanding of FXML CSS.

    According to this reference, each node in the scene graph can have substructures. For example in our case, TextArea has a substructure called content. It's this content that we should be looking to change and not the entire textarea. In this case:

    .text-area .content { -fx-background-color: red; }

    works perfectly for me. In other words, we have a region (called content) drawn on the main node (textarea).

    This also shows why many people would get only a, for example, red border when they try to change the background of an textarea to red. It's because that narrow border is the only part beneath the content visible to us.

    Hope this helps ...