FileDocCategorySizeDatePackage
ExpressionTreeCellRenderer.javaAPI DocExample1425Mon Nov 09 12:45:50 GMT 1998None

ExpressionTreeCellRenderer

public class ExpressionTreeCellRenderer extends JLabel implements TreeCellRenderer

Fields Summary
Color
backColor
boolean
isLeaf
Constructors Summary
public ExpressionTreeCellRenderer()


    // Pick a nice, big, fixed width font for our labels
    setFont(new Font("Monospaced", Font.PLAIN, 16));
    setHorizontalAlignment(SwingConstants.CENTER);
  
Methods Summary
public java.awt.DimensiongetPreferredSize()

    Dimension dim = super.getPreferredSize();
    if(dim != null) { dim = new Dimension(dim.width + 4, dim.height); }
    return dim;
  
public java.lang.StringgetToolTipText()

    if (isLeaf) { return "Leaf"; }
    return "Node";
  
public java.awt.ComponentgetTreeCellRendererComponent(javax.swing.JTree tree, java.lang.Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)

    if (selected) {
      setOpaque(true);
      setForeground(Color.white);
    }
    else {
      setOpaque(false);
      setForeground(Color.black);
    }
    setText(value.toString());
    isLeaf = leaf;
    return this;