JTree具有不同颜色的树线? [英] JTree with different colored tree lines?

查看:116
本文介绍了JTree具有不同颜色的树线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两个兄弟节点之间是否可能有不同的彩色树线?

is it possible to have different colored tree lines between two sibling nodes?

我想表明这两个节点是通过一条蓝线连接在一起的.但是,整个JTree默认颜色是灰色或黑色的斜线.某些节点之间可能会有部分不同的彩色线条吗?

I want to show that these two nodes are linked by having a blue line connecting them. However the entire JTree default color is grey or black angled line. Is possible to have partially different colored lines between certain nodes?

推荐答案

要更改树中线条的颜色,您需要将

To change the colours of the lines in the tree, you will need to subclass BasicTreeUI and override at least the 4 methods:

  • paintHorizontalLine
  • paintHorizontalPartOfLeg
  • paintVerticalLine
  • paintVerticalPartOfLeg

扩展BasicTreeUI的示例在这里找到

An example of extending BasicTreeUI can be found here

这篇关于JTree具有不同颜色的树线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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