ExpressionTreeCellRendererpublic 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.Dimension | getPreferredSize()
Dimension dim = super.getPreferredSize();
if(dim != null) { dim = new Dimension(dim.width + 4, dim.height); }
return dim;
| public java.lang.String | getToolTipText()
if (isLeaf) { return "Leaf"; }
return "Node";
| public java.awt.Component | getTreeCellRendererComponent(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;
|
|