Issue
I want to change color and font size of content of javafx.scene.text.Text
but couldn't seem to find the correct css. I used the following but there were no visible changes.
.text {
-fx-font-smoothing-type: lcd;
-fx-fill: white;
-fx-font-size: 11pt;
}
Can anyone please tell me how can I change the color and size of javafx.scene.text.Text
using css?
Solution
The content CSS is not available for Text node in javafx. If you apply .text{} it will apply to all button text and others but not to the Text node which you required.
But, you can use style class in css and use the same in fxml as given below.
.text-id {
-fx-font-smoothing-type: lcd;
-fx-fill: white;
-fx-font-size: 11pt;
}
Then in FXML,
<Text layoutX="238.0" layoutY="141.0" strokeType="OUTSIDE" strokeWidth="0.0" styleClass="text-id" text="NEW TEXT" />
I hope it will help you.
Answered By - Venkat Prasanna
Answer Checked By - Katrina (JavaFixing Volunteer)