Adding folder to tree

Hi,

I am using this code snippet to adding this node(directory) into tree and make

it visible in the File system view. I cann't use insert node into bcoz i am not using

defaultTreemodel.

TreePath selectedPath = tree.getSelectionPath();

File NewFile = new File(selectedPath.getLastPathComponent().toString(), "NewFolder");

NewFile.mkdir();

selectedPath = selectedPath.pathByAddingChild(NewFile);

tree.scrollPathToVisible(selectedPath);

tree.setSelectionPath(selectedPath);

tree.requestFocus();

FileBrowseTree class is my cutomized TreeModel.

These r the execption i am getting when i am trying to close(collapsing or expanding)

the parent node in which i have added the node recently.This May be bcoz of not updating the

tree model.

Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at FileBrowseTree.FileBrowseTree$3.valueChanged(FileBrowseTree.java:109)

at javax.swing.JTree.fireValueChanged(JTree.java:2399)

What would be the best way to insert the node into the tree?

Why i am facing this problem?

Thanks in advance,

Arun

[1255 byte] By [arun_a] at [2007-10-3 3:07:42]
# 1

I think your tree model class is not properly written.

Post a small demo code that is generally compilable, runnable and could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html and [url=http://riters.com/JINX/index.cgi/Suggestions_20for_20Asking_20Questions_20on_20Newsgroups]this wiki.[/url]

hiwaa at 2007-7-14 20:58:05 > top of Java-index,Desktop,Core GUI APIs...