简体   繁体   English

JavaFX样式相同类型的所有节点,例如VBox

[英]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.

相关问题 VBox中的节点宽度不同 - Nodes in VBox don't have the same width HTML:是否像SVG一样,坚持使用jQuery进行样式更改(例如,宽度,位置)? - HTML: persist style changes (e.g., width, position) made with jQuery as cleanly as SVG? Angular 8:如何设置组件本身的布局样式(例如,来自父组件?) - Angular 8: How to style the layout of a component itself (e.g., from a parent?) 是否可以使用 all 速记来取消设置元素的所有属性,除了某个属性(例如 display 属性)? - Is it possible to unset all properties of an element except a certain one (e.g. the display property) using the all shorthand? 在不同的浏览器/屏幕尺寸上显示两个相同的实际距离(例如,英寸)的对象 - Display two object same real distance (e.g. inches) apart across different browers / screen sizes 如何使用 React 多次添加相同的 CSS 属性(例如背景图像)? - How do I add the same CSS property (e.g. background-image) multiple times with React? 我希望文本随着图像缩小而缩小。 例如,相对于图像保持相同的大小比例 - I want the text to shrink as the image shrinks. e.g. maintain the same ratio in size relative to the image 将类型选择器与ID选择器组合在一起的好处是什么? 例如div#some_id - What are the advantages of combining a type selector with an id selector? e.g. div#some_id Workflowy-Stylebot-有没有一种方法可以设置css标签的样式,其中特定标签/项目以xxx开头(例如“ []”或“ evernote://”字符)? - Workflowy - Stylebot - Is there a way to style css tag where a particular tag/item starts with xxx (e.g. “[ ]” or “evernote://” characters? 带TitledPane的VBox的JavaFX填充 - JavaFX padding of VBox with TitledPane
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM