Changing Font of DefaultMutableTreeNode
From: Daniel Fabian (strap_at_fabiand.net)
Date: 03/27/04
- Next message: Babu Kalakrishnan: "Re: Changing Font of DefaultMutableTreeNode"
- Previous message: Alan Moore: "Re: Special characters in JTextField"
- Next in thread: Babu Kalakrishnan: "Re: Changing Font of DefaultMutableTreeNode"
- Reply: Babu Kalakrishnan: "Re: Changing Font of DefaultMutableTreeNode"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 27 Mar 2004 08:57:43 GMT
Hi!
I have a treenode and want to change the color and font of a treenode. I
have already implemented a TreeCellRenderer, but whenever I use that to
change the color of the font, the font of the whole tree changes. All I want
is to change a single TreeNode. What am I doing wrong?
private class LinkTreeCellRenderer extends DefaultTreeCellRenderer {
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);
Object nodevalue = null;
if (!(value instanceof DefaultMutableTreeNode))
return this;
nodevalue = ((DefaultMutableTreeNode)value).getUserObject();
if ((nodevalue instanceof Page) && ((Page)nodevalue.someattr)) {
setFont(this.getFont().deriveFont(Font.BOLD));
setTextNonSelectionColor(Color.BLUE);
}
return this;
}
}
Thanks in advance,
Daniel
- Next message: Babu Kalakrishnan: "Re: Changing Font of DefaultMutableTreeNode"
- Previous message: Alan Moore: "Re: Special characters in JTextField"
- Next in thread: Babu Kalakrishnan: "Re: Changing Font of DefaultMutableTreeNode"
- Reply: Babu Kalakrishnan: "Re: Changing Font of DefaultMutableTreeNode"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|