gpt4 book ai didi

JavaFX CSS 警告 : CSS Error parsing file : . ..:预期 LBRACE 在

转载 作者:技术小花猫 更新时间:2023-10-29 11:49:57 28 4
gpt4 key购买 nike

我最近问了一个关于在 JavaFX LineChart 上添加两条垂直线的问题,现在我在将一些样式内容应用到绘图时遇到了问题。我认为这是一个新问题,所以我打开了一个新线程。

Add Two Vertical Lines to LineChart

我的问题:如何更改系列的不同颜色?我还想将背景更改为白色。

以下是我创建的图表(它扩展了 LineChart):

LineChartWithMarkers<Number, Number> chart = new LineChartWithMarkers<Number, Number>(xAxis, yAxis, dataset);

xAxis.setLabel("time(s)");
yAxis.setLabel("deg/s");

chart.setStyle(".chart-series-line { -fx-stroke-width: 2px; -fx-effect: null; ");
chart.setStyle(".default-color0.chart-series-line { -fx-stroke: blue; }");
chart.setStyle(".default-color1.chart-series-line { -fx-stroke: red; }");
chart.setStyle(".default-color0.chart-line-symbol { -fx-stroke: blue, blue; }");
chart.setStyle(".default-color1.chart-line-symbol { -fx-stroke: red, red; }");
chart.setStyle(".chart-legend { -fx-background-color: transparent; }");

出于某种原因,这些代码不适用于图表。所以我尝试使用 CSS 文件。

CSS文件如下:

@CHARSET "ISO-8859-1";

.chart-series-line {
-fx-stroke-width: 1px;
-fx-effect: null;}

.default-color0.chart-series-line { -fx-stroke: blue; }
.default-color1.chart-series-line { -fx-stroke: red; }

.default-color0.chart-line-symbol { -fx-background-color: blue, blue; }
.default-color1.chart-line-symbol { -fx-background-color: red, red; }

.chart-legend {
-fx-background-color: transparent;
-fx-font-size: 0.75em;}

.chart-legend-item-symbol{
-fx-background-radius: 2;}

.chart-plot-background {
-fx-background-color: transparent;}

我试着关注Using JavaFX Charts: Styling Charts with CSS ,但我在控制台中收到的错误是“警告:CSS 错误解析文件:...:预期 [1,9] 处的 LBRACE”

我今天刚从 JDK 7 切换到 JDK 8,所以我不确定这是否与此有关...

感谢您的帮助!

最佳答案

@charset JavaFX CSS 不支持规则,它只是完整 W3C CSS 的一个子集。尝试将其删除。

@ Rules

Beginning with JavaFX 8u20, the CSS @import is also partially supported. Only unconditional import is supported. In other words, the media‑type qualifier is not supported. Also, the JavaFX CSS parser is non-compliant with regard to where an @import may appear within a stylesheet (see At‑rules). Users are cautioned that this will be fixed in a future release. Adherence to the W3C standard is strongly advised.

关于JavaFX CSS 警告 : CSS Error parsing file : . ..:预期 LBRACE 在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28973873/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com