gpt4 book ai didi

java - 我需要使用什么 CSS 语法来访问 JavaFX 中 TitledPane 的标签?

转载 作者:太空宇宙 更新时间:2023-11-04 12:49:02 31 4
gpt4 key购买 nike

我对 JavaFX 上下文中的 CSS 了解不多。我正在尝试访问某些 TitledPanes 的标签,以便我可以在标签旁边放置一个简单的图像,但我不知道这样做的正确语法是什么。

我试过:

.TitledPane > .title > .text { //TitledPane is the CSS class I assign to my Title Panes.
/*CSS Code Here*/
}

那没用。

.TitledPane > .title { } //This only affects the background, I would like the graphic to be side-by-side with the actual text.

.TitlePane LabeledText { } //This worked with Buttons so I thought it might work with TitledPane. I was wrong.

我需要使用什么来访问 Label 才能使用 CSS 设置样式?

最佳答案

CSS documentation for TitledPane似乎是错误的:如前所述,标题中的 text 类实际解析为 Text 对象,而不是 Label。当然,Text 不支持 -fx-graphic css 属性。

幸运的是,由于 TitledPane 扩展了 Labeled,您可以直接使用 Labeled 中定义的属性:

.TitledPane {
-fx-graphic: url(path/to/image/file) ;
}

关于java - 我需要使用什么 CSS 语法来访问 JavaFX 中 TitledPane 的标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26283633/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com