简体   繁体   English

替换JTree手柄图标

[英]Replace JTree handle icons

I'm trying to customize a JTree so that I can use it in a project that I'm working on. 我正在尝试自定义JTree以便我可以在我正在处理的项目中使用它。 That project GUI's style does not fit the default Java LNF's node handles for JTree which is why I tried to replace them with custom-made icons but I'm stuck as to how I can do that. 那个项目的GUI样式不适合JTree的默认Java LNF节点句柄,这就是为什么我试图用定制的图标替换它们但是我不知道如何做到这一点。 I don't know if that helps but I already have an own LNF class which loads the default LNF settings and overrides some of them with custom values. 我不知道这是否有帮助,但我已经有了一个自己的LNF类,它加载默认的LNF设置并用自定义值覆盖其中一些设置。

Alternatively, if replacing the handles' icons is too complex to explain it in an answer here, how can I completely disable them so that I can use custom open/closed icons for all expandable nodes? 或者,如果更换手柄的图标太复杂,无法在此处的答案中解释,我怎样才能完全禁用它们,以便我可以为所有可扩展节点使用自定义打开/关闭图标?

By setting the UIManager properties Tree.collapsedIcon (for collapsed handles) and Tree.expandedIcon (for expanded handles) to the desired values, the handles for all JTree s can be changed at once. 通过将UIManager属性Tree.collapsedIcon (对于折叠的句柄)和Tree.expandedIcon (对于展开的句柄)设置为所需的值,可以立即更改所有JTree的句柄。 Thanks to @MadProgrammer for suggesting the examples shown here , here , here and here . 感谢@MadProgrammer 建议 这里这里这里这里显示的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM