Sreejith22
asked on
How to refresh a particular directory in a Jtree
Hi,
Based on this thread, https://www.experts-exchange.com/questions/23793040/Jtree-implementation-based-on-structure-given.html
can anyone please say, how to refresh a particular directory alone, whenever needed.
zzynx, i have reposted this question as per your suggestion. Hope I am clear with my question.
Please provide some help.
Warm Regards,
Sreejith
Based on this thread, https://www.experts-exchange.com/questions/23793040/Jtree-implementation-based-on-structure-given.html
can anyone please say, how to refresh a particular directory alone, whenever needed.
zzynx, i have reposted this question as per your suggestion. Hope I am clear with my question.
Please provide some help.
Warm Regards,
Sreejith
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
myTree class?
I'm not aware of the fact that you have your own myTree class...
I'm not aware of the fact that you have your own myTree class...
ASKER
I named the class in which I declare and create the tree as myTree.java
My question is, I get the child vector corresponding to a particular directory with myNode.getChildren()
Though we add it to the child vector as
>>children.add( new MyNode(dirEntry1.filename, dirEntry1.attributes.isDir ectory()) ); , i get the output in the form [my_share, jj, my_music, my_pictures, my_video, New Folder (2), search_off.png, booodrive.png, src.rar] , which is OK for me.
But , when I perform the below mentioned, I get the exception given.
for(Enumeration e = myNode.getChildren().eleme nts(); e.hasMoreElements();)
{
Object o = e.nextElement();
nomSelection =((SFTPv3DirectoryEntry)o) .filename;
....................
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastExcepti on: booodrive.MyNode cannot be cast to com.trilead.ssh2.SFTPv3Dir
ectoryEntry
at booodrive.myTree.createFil eVector(my Tree.java: 958)
I know that what is inside that vector is a MyNode object, but how can I cast this?
My question is, I get the child vector corresponding to a particular directory with myNode.getChildren()
Though we add it to the child vector as
>>children.add( new MyNode(dirEntry1.filename,
But , when I perform the below mentioned, I get the exception given.
for(Enumeration e = myNode.getChildren().eleme
{
Object o = e.nextElement();
nomSelection =((SFTPv3DirectoryEntry)o)
....................
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastExcepti
ectoryEntry
at booodrive.myTree.createFil
I know that what is inside that vector is a MyNode object, but how can I cast this?
>> I know that what is inside that vector is a MyNode object, but how can I cast this?
Well, you only can get the information out of a MyNode object that you previously put in.
I don't know how your constructChildren() method and your MyNode object currently looks like,
but if constructChildren() still contains the line I suggested:
children.add( MyNode(dirEntry1.filename, dirEntry1.attributes.isDir ectory()) );
you see that in your MyNode object you store the filename, so you could write:
for(Enumeration e = myNode.getChildren().eleme nts(); e.hasMoreElements();) {
MyNode node = (MyNode)e.nextElement();
nomSelection = node.getName();
...
}
Well, you only can get the information out of a MyNode object that you previously put in.
I don't know how your constructChildren() method and your MyNode object currently looks like,
but if constructChildren() still contains the line I suggested:
children.add( MyNode(dirEntry1.filename,
you see that in your MyNode object you store the filename, so you could write:
for(Enumeration e = myNode.getChildren().eleme
MyNode node = (MyNode)e.nextElement();
nomSelection = node.getName();
...
}
ASKER
ok..thanks very much, I am implementing the refresh for a directory..after that I will close this thread.
thx, again.
thx, again.
ASKER
I am implementing drag and drop. Everything works fine for me. But one problem occured while implementing this. The solution of which requires me to have the following detail.
If at any time, I select a particular item in a directory(say, directory x), how can I get the children vector of that directory(directory x) from MyNode?
I tried different methods, sorry to say that with my limited knowledge, i could not get the desired vector.
If possible, please help.
If at any time, I select a particular item in a directory(say, directory x), how can I get the children vector of that directory(directory x) from MyNode?
I tried different methods, sorry to say that with my limited knowledge, i could not get the desired vector.
If possible, please help.
>> how can I get the children vector of that directory(directory x) from MyNode?
getChildren() returns the Vector containing the children (also MyNode object's again)
getChildren() returns the Vector containing the children (also MyNode object's again)
ASKER
Thanks alot zzynx, soln. was awesome
ASKER
Thanks alot zzynx, solution was awesome and line by line accurate.
You're welcome.
Thanx 4 axxepting
Thanx 4 axxepting
ASKER