JavaFX2:设置单个TreeItem样式的最佳方法是什么? [英] JavaFX2: What is the best way to style an individual TreeItem?

查看:330
本文介绍了JavaFX2:设置单个TreeItem样式的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够将CSS类添加到TreeItem,然后仅使用CSS文件来为其赋予样式.但这是不可能的,或者是吗?

I would have liked to have the ability to add a CSS class to the TreeItem and then just use a CSS file to give it style. But that is not possible, or is it?

是否可以像使用getStyleClass()一样添加类?

Is there a way to add a class like we can using getStyleClass()?

如果没有,给单个项目赋予样式的最佳方法是什么?

If not, what is the best way to give individual items a style?

推荐答案

使用

Use a TreeCellFactory , and in the factory, use a Node and set it's style, either via getStyle, or even better via Node.setStyleClass.

这篇关于JavaFX2:设置单个TreeItem样式的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆