hi im working on a program that when you add a folder into the jtree it show up all the files in it and it is save
automatically when the windows is closing with writeobject
but atm i have a problem with displaying the file when i click on a node in the jtree
i think it might be because of the treepath
atm its show me this [root, D:\\Word, D:\\Word\\abbb.txt]
i would like to be able just to show the " D:\\Word\\abbb.txt "
so when i call the bufferedReader File
it show up all the contents of the file in the jtextarea area
here is my code
i would need this big help
im new in jtree and im learning it by myself so ty in advance
here is my full code and the code in bold is where the problem is
The TreePath API docs indicate that TreePath doesn't do what you think it does: you're seeing a string representation of the entire path ending with your filename. If you were deeper in the tree you'd have more items.
cool im gonna work on it but ty for the help David yeah i think i need to work with the getLastPathComponent function like you said
p.s. i have an another version of all this with the StyleDocument ( bold italic )
i might send most of the code that work out so you guys can see the result
if i still have trouble with this
im gonna reply
and ty for the help again
Efstathios Arethas
Greenhorn
Joined: Jun 07, 2009
Posts: 5
posted
0
Hi
you are using String file = tp.toString(); which means ! show the TreePath tp as a string by using the toString method , i think you must override this toString method from the TreePath , you can make another class like MyTreePath extends Treepath and override the toString method there , you can use this MyTreepath instead of TreePath
it uses a loop , as you can see a StringBuffer which just adds this with the append method! just change it! By the way you should use StringBuffer too!
Efstathios Arethas wrote:you are using String file = tp.toString(); which means ! show the TreePath tp as a string by using the toString method , i think you must override this toString method from the TreePath , you can make another class like MyTreePath extends Treepath and override the toString method there , you can use this MyTreepath instead of TreePath
Why override JTree to provide something it already provides?
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: showing a text file from a jtree selection path