CSS颜色分析错误(CSS Color Parsing Error)

编程入门 行业动态 更新时间:2024-10-22 20:22:28
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;" };

更多推荐

本文发布于:2023-08-05 17:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1435745.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:颜色   错误   CSS   Error   Parsing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!