1

I get the error message:

Jun 25, 2014 11:39:18 AM com.sun.javafx.css.parser.CSSParser term
WARNING: CSS Error parsing '*{-fx-background-color:8ACC49;}: Unexpected token '8ACC' at [1,23]

I have an array of styles to set the background color:

private final String[] colors = new String[] { 
    "-fx-background-color:49CC49;",
    "-fx-background-color:5FCC49;",
    "-fx-background-color:8ACC49;", 
    "-fx-background-color:A0CC49;", 
    "-fx-background-color:CCCC49;", 
    "-fx-background-color:CCB649;", 
    "-fx-background-color:CC8A49;", 
    "-fx-background-color:CC7449;", 
    "-fx-background-color:CC4949;" };

Originally I just used the HEX values in the array, but the same error occurred as now. Populating the styles in the array was my second attempt to solve the problem. Also I had spaces around the colons, same error.

I used the following to set the style:

@FXML private Label lbl;

...

lbl.setStyle(color);

Only the first 3 colors give the error message.

2
  • 3
    Shouldn't the hex values be preceded by a #, as in #49CC49? Commented Jun 25, 2014 at 9:55
  • Yes in fact I just remembered it haha. Commented Jun 25, 2014 at 9:55

1 Answer 1

1

You Missed # before the Color hex value . this code should be this:

private final String[] colors = new String[] { 
    "-fx-background-color:#49CC49;",
    "-fx-background-color:#5FCC49;",
    "-fx-background-color:#8ACC49;", 
    "-fx-background-color:#A0CC49;", 
    "-fx-background-color:#CCCC49;", 
    "-fx-background-color:#CCB649;", 
    "-fx-background-color:#CC8A49;", 
    "-fx-background-color:#CC7449;", 
    "-fx-background-color:#CC4949;" };
Sign up to request clarification or add additional context in comments.

1 Comment

Aso if you have your value in format 0x49CC49 it will throw a related error too

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.