CSS颜色分析错误(CSS Color Parsing Error)
我收到错误消息:
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]我有一系列样式来设置背景颜色:
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;" };最初我只使用了数组中的HEX值,但是现在出现了同样的错误。 填充数组中的样式是我第二次尝试解决问题。 我在冒号周围也有空格,同样的错误。
我使用以下设置样式:
@FXML private Label lbl; ... lbl.setStyle(color);只有前3种颜色给出错误信息。
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.
最满意答案
您在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;" };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;" };更多推荐
发布评论