N
Neeraj
hi,
this is my code summary:-
class DirectoryTreeModel implements TreeModel
{
public void addTreeModelListener(TreeModelListener l)
{
}
public Object getChild(Object parent, int index)
{
Directory dir = (Directory)parent;
return dir.getChild(index);
}
public int getChildCount(Object parent)
{
Directory dir = (Directory)parent;
if (!dir.isExpanded())
{
return 0;
}
return dir.getChildCount();
}
public int getIndexOfChild(Object parent, Object child)
{
Directory dir = (Directory)parent;
if (!dir.isExpanded())
{
return -1;
}
return dir.getChildIndex((Directory)child);
}
public Object getRoot()
{
return root;
}
public boolean isLeaf(Object node)
{
Directory dir = (Directory)node;
return dir.isLeaf();
}
public void removeTreeModelListener(TreeModelListener l)
{
}
public void valueForPathChanged(TreePath path, Object newValue)
{
DefaultMutableTreeNode
node;
node =
(DefaultMutableTreeNode)(arg0.getTreePath().getLastPathComponent());
String s = file.getPath();
String parent = file.getParent();
File file = new File(s);
File newfile = new File(parent+File.separator+newValue);
file.renameTo(newfile);
tree.repaint();
}
}
this is class which implement TreeModel used in my tree.
When i run this program then java.lang.ClassCastException: is
generated on node = (Def...) line. so i cannot apply changed name on
that node.
i m stuck here how can i uses this node.
i cannot use any other model.
any one have some idea plz write me for that i m thankful to you.
bye
Happy Sankrantri and Pongal to all of you.
this is my code summary:-
class DirectoryTreeModel implements TreeModel
{
public void addTreeModelListener(TreeModelListener l)
{
}
public Object getChild(Object parent, int index)
{
Directory dir = (Directory)parent;
return dir.getChild(index);
}
public int getChildCount(Object parent)
{
Directory dir = (Directory)parent;
if (!dir.isExpanded())
{
return 0;
}
return dir.getChildCount();
}
public int getIndexOfChild(Object parent, Object child)
{
Directory dir = (Directory)parent;
if (!dir.isExpanded())
{
return -1;
}
return dir.getChildIndex((Directory)child);
}
public Object getRoot()
{
return root;
}
public boolean isLeaf(Object node)
{
Directory dir = (Directory)node;
return dir.isLeaf();
}
public void removeTreeModelListener(TreeModelListener l)
{
}
public void valueForPathChanged(TreePath path, Object newValue)
{
DefaultMutableTreeNode
node;
node =
(DefaultMutableTreeNode)(arg0.getTreePath().getLastPathComponent());
String s = file.getPath();
String parent = file.getParent();
File file = new File(s);
File newfile = new File(parent+File.separator+newValue);
file.renameTo(newfile);
tree.repaint();
}
}
this is class which implement TreeModel used in my tree.
When i run this program then java.lang.ClassCastException: is
generated on node = (Def...) line. so i cannot apply changed name on
that node.
i m stuck here how can i uses this node.
i cannot use any other model.
any one have some idea plz write me for that i m thankful to you.
bye
Happy Sankrantri and Pongal to all of you.