Harshita Sethi
Harshita Sethi

Reputation: 2125

Css for javafx.scene.text.Text

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?

Upvotes: 7

Views: 9990

Answers (2)

Zyxl
Zyxl

Reputation: 124

As stated in the CSS reference guide, Text doesn't have any default style classes. However, the CSS selector Text can be used:

Text { 
 -fx-font-smoothing-type: lcd;
 -fx-fill: white;
 -fx-font-size: 11pt;
}

Upvotes: 1

Venkat Prasanna
Venkat Prasanna

Reputation: 732

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.

Upvotes: 8

Related Questions