Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含多个 fxml 文件的 JavaFX 项目(在 NetBeans 中)。有没有办法为这些 fxml 文件中的每一个分配单独的 css 文件?我想为每个 fxml 做不同的 .root{...} 设置。可能吗?
FXML将关联文件添加到每个css文件:
FXML
css
<stylesheets> <URL value="@stylesheet.css" /> </stylesheets>
确保它stylesheet.css位于CLASSPATH.
stylesheet.css
CLASSPATH
编辑:如果您想要一个全局文件css用于多个fxml文件,请将 添加到您的文件fx:id的根窗格中,并在您的,中使用默认值。fxmlIDcssroot
fxml
fx:id
ID
root
#fxml_1 { ... style from the fxml file with fx:id = "fxml_1", and so on }