Yes you can do this. You'll have to create your
own treeCellRenderer and then overwrite the
method:
public Component getTreeCellRendererComponent(
JTree tree, Object value, boolean selected, boolean expanded,
boolean leaf, int row, boolean hasFocus)
in this you can do something similar to:
// Get the current component
Component c = super.getTreeCellRendererComponent
(tree, value, selected, expanded, leaf, row, hasFocus);
// Now change the icon if possible necessary
if (c instanceof JLabel )
{
JLabel l = (JLabel)c;
// If it's a leaf use a study, if not use studies
if ( leaf == true )
label.setIcon(studyIcon_);
else
label.setIcon(studiesIcon_);
}
You can put as much logic as you need to here.
Jeff
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of sujay
Sent: Saturday, February 06, 1999 9:57 AM
To: [EMAIL PROTECTED]; Swing
Subject: JTree question
hi all,
i was wondering if it is possible to assign different icons depending
on some value
to the various leaves in a tree.
Example:
---Numbers
|--1 to 10
|--11 to 20
|--11
|--12
|--13
|--14
|--15
|--16
|--17
|--18
|--19
|--20
|--21 to 30
|--31 to 40
................... etc.
what i want to do is i want all the odd numbers with one icon and all even
number with
another. can any body help me do this.
thanX in advance
~S
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing
_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing