[英]JavaFX style all nodes of the same type, e.g., VBox
I have lots of fxml files containing different types of javafx nodes such as VBox, etc. I want to know if it is possible to add a stylesheet to the scene which automatically applies on all VBox elements declared any where in my project (or even created programatically). 我有很多包含不同类型的javafx节点的fxml文件,比如VBox等。我想知道是否可以在场景中添加样式表,它自动应用于我项目中任何位置声明的所有VBox元素(甚至创建)编程)。 I know that it is easily supported for buttons , since I can use .button {...} inside my custom .css file and add it to the scene.
我知道按钮很容易支持,因为我可以在我的自定义.css文件中使用.button {...}并将其添加到场景中。 However, I can't find anything similar solution for lots of node types such as VBox, HBox, and so on.
但是,我找不到任何类似的解决方案,适用于许多节点类型,如VBox,HBox等。
I looked for such css tags like VBox inside modena.css which is placed somewhere inside standard jdk's jfxrt.jar. 我在modena.css里寻找像VBox这样的css标签,它放在标准的jdk的jfxrt.jar里面。 Unfortunately, I could not find such tags.
不幸的是,我找不到这样的标签。 I could not find any example on the oracle's website too.
我在oracle的网站上也找不到任何例子。
Is there any way of doing so? 有没有办法这样做? Thanks for your helps.
谢谢你的帮助。
I myself found a solution. 我自己找到了解决方案。 You can add this simple class name of a pane such as VBox to your .css file like this:
您可以将此窗格的简单类名称(如VBox)添加到.css文件中,如下所示:
HBox, VBox {
//css instructions here
-fx-background-color: red;
}
Note that names are case sensitive; 请注意,名称区分大小写; No dot is required before the name.
名称前不需要任何点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.