-fx-border-style 在运行时看起来不像预期的那样,但在 SceneBuilder 上

-fx-border-style doesn't look as expected on runtime but on SceneBuilder

以下样式在 SceneBuilder 上看起来符合预期。 (唯一可见的边框是底部边框,它是虚线的。)

但在运行时看起来不一样。 (所有边框都可见且实心。)

.floatingPanel-title{
  -fx-text-alignment: center;
  -fx-text-fill: CORNFLOWERBLUE;
  -fx-font-weight: bold;
  -fx-font-size: 15px;
  -fx-background-color: #545050;
  -fx-border-style: none none dotted none;
  -fx-border-color: white;
}

我通过交换行或注释掉某些部分来尝试一些,但问题仍然存在。

您有什么建议作为解决方案?

注:

1) 我将此样式应用于标签和面板。该问题对两者都有效。

2) 我已经尝试过clean-compile。问题依然存在。

这似乎是一个错误,抱歉。在我使用 JavaFX 8u40 进行测试时:

1) 尽管官方 JavaFX CSS Reference Guide-fx-border-style 上说

A series of border style values, separated by commas. Each item in the series applies to the corresponding item in the series of border colors.

逗号分隔的例子比没有逗号分隔的例子表现得奇怪和错误。即这些

  -fx-border-style: dotted  dashed  dashed  dashed;
  -fx-border-color: red red red red;
  -fx-border-width: 2;

  -fx-border-style: dotted , dashed  , dashed  , dashed;
  -fx-border-color: red red red red;
  -fx-border-width: 2;

呈现方式不同。尽管有文档,但不使用逗号似乎更准确。

2) 边框样式选项 none 在 JavaFX 8 中不起作用,但在 JavaFX 2 中起作用。您可以选择使用 hidden.

代替它
-fx-border-style: hidden hidden dotted hidden;

3) SceneBuilder和运行时的渲染不同可能是使用不同版本的JavaFX造成的。您可以通过

检查使用的版本
System.out.println(com.sun.javafx.runtime.VersionInfo.getRuntimeVersion());

最后,在观察自己之后,欢迎您提交一个 jira 问题或为现有问题投票。