1 4 package com.tc.admin.common; 5 6 import java.awt.Component ; 7 8 import javax.swing.JTree ; 9 import javax.swing.tree.TreeCellRenderer ; 10 11 15 16 public class XTreeCellRendererDelegate implements TreeCellRenderer { 17 protected XTreeCellRenderer m_defaultRenderer; 18 19 public XTreeCellRendererDelegate() { 20 m_defaultRenderer = new XTreeCellRenderer(); 21 } 22 23 protected TreeCellRenderer getNodeRenderer(Object value) { 24 TreeCellRenderer nodeRenderer = null; 25 26 if(value instanceof XTreeNode) { 27 nodeRenderer = ((XTreeNode)value).getRenderer(); 28 } 29 30 return nodeRenderer != null ? nodeRenderer : m_defaultRenderer; 31 } 32 33 public Component getTreeCellRendererComponent( 34 JTree tree, 35 Object value, 36 boolean sel, 37 boolean expanded, 38 boolean leaf, 39 int row, 40 boolean focused) 41 { 42 return 43 getNodeRenderer(value).getTreeCellRendererComponent( 44 tree, value, sel, expanded, leaf, row, focused); 45 } 46 } 47 | Popular Tags |