reminder.......


Hi all,

I am reading the directory structure and displaying in Jtree.
for e.g root dir(/) and two files abc.txt and b.java and i am also
displaying two files
abc.txt and b.java

for example

abc.txt            20        bytes        2001-06-03 11.30 PM
b.java             345      bytes        2001-06-03 12.30 PM


i am sending this str to be displayed in the tree.

when the jtree displays the string it is not in the above format..


/
    abc.txt            20        bytes          2001-06-03 11.30 PM
    b.java        345        bytes        2001-06-03 12.30 PM


I am using treecellrenderer, i have tried different options I dont know
why this is happening, is there any thing to do with the label.

Could any one throw light on this......


this the method for treecellrenderer

public Component getTreeCellRendererComponent(JTree tree, Object value,
        boolean selected, boolean expanded,
        boolean leaf, int row,
        boolean hasFocus) {
 Font            font;
 String          stringValue = tree.convertValueToText(value, selected,
        expanded, leaf, row, hasFocus);

 /* Set the text. */
    // find dir name from path
 StringTokenizer sz = new StringTokenizer(stringValue,"/");
 String str = null;
 while(sz.hasMoreTokens())
 {
     str = (String)sz.nextElement();
     str = str.trim();
 }
 // add / to dir
 if (stringValue.endsWith("/"))
     str += "/";
 // display str for current dir
 if (stringValue.equals(rootStr))
     str = "  /";

 setText(str);
 /* Tooltips used by the tree. */
 setToolTipText(stringValue);

 /* Set the image. */
 if(expanded && expandedIcon != null)
     setIcon(expandedIcon);
 else if(!leaf && collapsedIcon != null)
     setIcon(collapsedIcon);
 else
     setIcon(null);

 /* Set the color and the font based on the SampleData userObject. */
 String         userObject = (String)((DefaultMutableTreeNode)value)
                                 .getUserObject();
 /* Update the selected flag for the next paint. */
 this.selected = selected;
 return this;
    }



raviprakash



Reply via email to