如何让树中过长的叶子内容分多行显示,不需要滚动条来完成。让每行叶子的内容一样多。

解决方案 »

  1.   

    自己写个修饰器...
    public Component getTreeCellRendererComponent(JTree tree, Object value,
                boolean sel, boolean expanded,
                boolean leaf, int row,
                boolean hasFocus){
                super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                                                   row,
                                                   hasFocus);
                if(leaf){
                    //页子结点做动作
                      JLable l = new JLable();
                    //JLable好像没有方法换行的,但是swing是支持HTML语法的,所以<html>dfsdf<br>lhlkk</html>就行了
                        ...........
                    return l;
                }
                return this;
            }
    ....只是个思路,自己试试
      

  2.   

    直接用<html>aaa<br>bbb</html>试试
      

  3.   

    我是GUI的编程,不是WEB的东西
      

  4.   

    我们都知道你是GUI编程呀
    setText("<html>aaa <br>bbb </html>");