1 package net.sf.openrocket.gui.main.componenttree;
5 import java.awt.Component;
7 import javax.swing.JTree;
8 import javax.swing.tree.DefaultTreeCellRenderer;
10 import net.sf.openrocket.gui.main.ComponentIcons;
11 import net.sf.openrocket.rocketcomponent.RocketComponent;
12 import net.sf.openrocket.util.TextUtil;
14 public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
17 public Component getTreeCellRendererComponent(
26 super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
29 setIcon(ComponentIcons.getSmallIcon(value.getClass()));
32 RocketComponent c = (RocketComponent) value;
33 String comment = c.getComment().trim();
34 if (comment.length() > 0) {
35 comment = TextUtil.htmlEncode(comment);
36 comment = "<html>" + comment.replace("\n", "<br>");
37 this.setToolTipText(comment);
39 this.setToolTipText(null);