I had a Java FXML application functioning in Java 7u51 that I built in NetBeans 7.4. I have installed Java 8 and NetBeans 8. I recreated my little application in Java 8/NetBeans 8. Everything is working except some of the css styling. Specifically, I have a Text Area.
Here is the Text Area FXML:
<TextArea layoutX="1" layoutY="230" minHeight="120" minWidth="320" editable="false" fx:id="eventWindow" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.bottomAnchor="0.0"/>
Here is the corresponding css styling:
#eventWindow {
-fx-background-color: black;
-fx-text-fill: white;
}
When I run the application, the background of my text area stays white! What's frustrating is that other things from my css file are behaving as they should. I have already tried the following:
1) I tried putting this in my css:
.events {
-fx-background-color: black;
-fx-text-fill: white;
}
...and adding 'styleclass="events"' into my FXML.
2) and I tried:
.textarea {
-fx-background-color: black;
-fx-text-fill: white;
}
no dice on either of those.
I have also double-checked to make sure that nothing could be overriding it. And... it's working just fine in Java 7u51.
I know this is not the most critical thing on the planet... but it's driving me nuts!
Thanks in advance! -Adeena
The problem is that the TextArea consist of several nodes (TextArea,ScrollPane,Content). To change the background of the content node the following css can be used:
.text-area .scroll-pane .content{
-fx-background-color: black;
}
The substructure of nodes is explained in the JavaFX css documentation: http://download.java.net/jdk8/jfxdocs/javafx/scene/doc-files/cssref.html#textarea
Here's a link to a related issue: https://javafx-jira.kenai.com/browse/RT-31904
in the fxml styleClass="eventWindow"
and then in the css
.eventWindow { -fx-background-color: black; -fx-text-fill: white; }
works for me
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.