JTree 线条样式和 Nimbus
我正在使用 Nimbus 的外观和感觉。根据这个链接,您应该能够实现JTree 具有 3 种不同的线条样式:
使用以下代码时:
theTree.putClientProperty("JTree.lineStyle", "Horizontal");
我的 JTree 如下所示:
它具有“无”样式,而不是“水平”样式。知道为什么会这样吗?和Nmbus有关系吗?设置该属性后我需要调用一些特殊的东西吗?
谢谢
I am using the Nimbus look and feel. According to this link, you should be able to achieve 3 different line styles with your JTree:
While using the following code:
theTree.putClientProperty("JTree.lineStyle", "Horizontal");
My JTree looks like this:
It has the "None" style and not the "Horizontal" style. Any idea why this might be? Does it have something to do with Nmbus? Do I need to call something special after setting that property?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不相信 Nimbus 支持
JTree.lineStyle
属性。只有 MetalLookAndFeel 可以。查看
javax.swing.plaf.synth.SynthTreeUI
(由 Nimbus 使用)和MetalTreeUI
(由 Metal 使用)的源代码。更改为 MetalLookAndFeel 并查看是否有效。
I don't believe Nimbus supports the
JTree.lineStyle
property. Only the MetalLookAndFeel does.Take a look at the source code for
javax.swing.plaf.synth.SynthTreeUI
(which is used by Nimbus) andMetalTreeUI
(which is used by Metal).Change to MetalLookAndFeel and see if it works.
事实证明,您可以通过执行“不完美,但接近”来获得一些这种效果
。
Turns out you can get some of this effect by doing
Not perfect, but close.
对于仍然对此感兴趣的人:
以下代码片段对我有用。
For anyone still interested in this:
The following snippet is working for me.