FXML将关联文件添加到每个css文件:
<stylesheets>
<URL value="@stylesheet.css" />
</stylesheets>
确保它stylesheet.css位于CLASSPATH.
编辑:如果您想要一个全局文件css用于多个fxml文件,请将 添加到您的文件fx:id的根窗格中,并在您的,中使用默认值。fxmlIDcssroot
#fxml_1 {
... style from the fxml file with fx:id = "fxml_1", and so on
}