I am creating a property management system for the desktop, and now I am working on the payment submission function. I want the payment amount to be highlighted in a different color on my label to improve readability.
I tried the following approach:
String datePaid = "just now";
Label amount = new Label("350");
Label label2 = new Label("paid £" + amount.getText() + " " + datePaid);
Then I tried to apply the following CSS
amount.setStyle("-fx-text-fill: #000 !important; -fx-highlight-text-fill: #000 !important; -fx-font-family: Arial");
label2.setStyle("-fx-text-fill: #fff; -fx-font-size: 14px; -fx-translate-x: -36; -fx-translate-y: 24; -fx-font-family: 'Open Sans Light'");
I thought by declaring !importantI would override the styles used in label2, but instead, all the text is displayed on screen in #fff
How can I achieve the desired result?
source
share