Sinisterly
Need some serious java help - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Java, JVM, & JRE (https://sinister.li/Forum-Java-JVM-JRE)
+--- Thread: Need some serious java help (/Thread-Need-some-serious-java-help)



Need some serious java help - Jacob - 08-06-2014

Well considering some of the best java programmers i know are on here, it doesn't hurt to ask!

I've had this problem for a 2 days and its really discouraging. Sad

I'm really new to JTree and its related classes, so sorry if this is mega easy!

I posted on SOF but alas, no help.
http://stackoverflow.com/questions/25131099/filter-results-in-jtree-based-on-input-from-jtextfield


RE: Need some serious java help - Psycho_Coder - 08-06-2014

I don't think I clearly understand your problem Sir. But what appears to me is like this :-

You have a directory D with different subdirectories SD and you have files of different extension and you want to update the JTree when you search for files maintaining the directory hierarchy or structure ?

You said you want you edit the files. I think you would be able to get the location of the files and then add an action listener to them and open them in TextComponent.

You might have a look here :- http://stackoverflow.com/questions/16771993/jtree-file-filter-and-folder-filter
http://www.java2s.com/Tutorial/Java/0240__Swing/JTreenodemouseclickevent.htm

For dynamic Update

http://stackoverflow.com/questions/11671242/how-to-show-the-dynamic-update-on-jtree-how-to-refresh-or-reload-a-jtree

For fast string matching you can use Boyer Moore.

I haven't looked into your code properly since I still have doubt what kind of problem you're actually facing.


RE: Need some serious java help - Deque - 08-06-2014

Posted an answer: https://stackoverflow.com/questions/25131099/filter-results-in-jtree-based-on-input-from-jtextfield/25169212#25169212
Try the solution and see if it works as expected.


RE: Need some serious java help - Jacob - 08-07-2014

(08-06-2014, 09:07 PM)Deque Wrote: Posted an answer: https://stackoverflow.com/questions/25131099/filter-results-in-jtree-based-on-input-from-jtextfield/25169212#25169212
Try the solution and see if it works as expected.

Hey, it works just as expected! It seems that I should've been more recursive about it. I went on to writing a filter method that instead of rebuilding the tree, just remove the nodes that didn't match criteria. However, I ran into a small problem there (didn't attempt to fix due to work).

Thanks Deque!