如何根据JTree节点信息不同改变节点图案? 如题~~就是说能不能让JTree的同一种节点(叶子节点)在同样的情况下(一样是被打开)却使用不同的icon?谢谢了~~DefaultTreeCellRenderer好象只能在描绘时使用一种icon。如果不行,能不能在UI描绘的时候加入我自己的代码?这个描绘的过程在哪里呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写一个类,扩展JLabel,实现TreeCellRenderer接口,在下面的方法中根据value设置不同的iconpublic Component getTreeCellRendererComponent(JTree tree,Object value, boolean isSelected,boolean expanded, boolean leaf,int row,boolean hasFocus) 比如,你的节点对象有一个getIcon方法,可得到不同的icon,那么MyNode node=(MyNode)value;setIcon(node.getIcon()); String数组排序 jsp页面 求Java Swing图形化用户接口设计的电子书籍 类与接口转型的问题 Jlist 菜鸟求助 java.lang.reflect.InvocationTargetException 免费打工~! 如何得到一个bmp的BufferedImage? 请问怎样用正则表达式剔除网页上的html标记呢 救救我,jb7怎么注册不了 求加密算法:用JAVA实现apache的htpasswd功能 看教程里的一道题不懂
在下面的方法中根据value设置不同的icon
public Component getTreeCellRendererComponent(JTree tree,Object value,
boolean isSelected,boolean expanded,
boolean leaf,int row,boolean hasFocus)
比如,你的节点对象有一个getIcon方法,可得到不同的icon,那么
MyNode node=(MyNode)value;
setIcon(node.getIcon());