Java:JTree带有正/负图标,用于扩展和折叠? [英] Java: JTree with plus/minus icons for expansion and collapse?

查看:337
本文介绍了Java:JTree带有正/负图标,用于扩展和折叠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使我的Jtree看起来像下面的东西,加号和减号图标允许扩展和折叠?



目前,默认的JTree只有在双击时才会展开和折叠。我想覆盖这个双击以获得另一个功能,让用户只需点击下面的减号和加号图标即可展开/折叠树。



解决方案

< blockquote>

带加号和减号图标,允许扩展和折叠?


这些是Windows LAF的默认图标。其他LAF有不同的图标。



您可以使用UIManager设置自己的图标。请参阅 UIManager Defaults



或者您只能为单个JTree使用自定义图标。请参阅自定义树的显示


让用户只需点击下面的减号和加号图标即可展开/折叠树。


这是默认行为。


How do I make my Jtree look like something below, with plus and minus icons that allows expansion and collapse?

Currently, the default JTree only expands and collapses when you double click. I want to override this double click for another functionality and let the user expand/collapse the tree by only clicking on the minus and plus icons such as below.

解决方案

with plus and minus icons that allows expansion and collapse?

These are the default icons for the Windows LAF. Other LAF's have different icons.

You can set your own icons by using the UIManager. See UIManager Defaults.

Or you can use custom icons for a single JTree only. See Customizing a Tree's Display.

let the user expand/collapse the tree by only clicking on the minus and plus icons such as below.

This is the default behaviour.

这篇关于Java:JTree带有正/负图标,用于扩展和折叠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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