Finding and then displaying an item in a FileTreeComponent


In my app there’s a FileTreeComponent which is used to display the HD’s content.
I want the user to search a file by entering a text fragment of it and pressing Enter. After pressing Enter this File should be shown in the FileTreeComponent, even if it was not fully opened.

For example, the FileTreeComponent shows the 2 directories:


Then the user enters “De la Soul” and presses Enter. The File “De la Soul - Ring Ring Ring” is located in the directory “MyMusic/De La Soul” and so the FileTreeComponent should look like this:

De La Soul
De La Soul - Ring Ring Ring …

How do I achieve this? I have no clue how to do it at the moment, because it seems that only the viewed TreeViewItems are already part of the FileTreeComponent, not the ones that are not viewed.


You’re really trying to use that component for more than it was ever intended! I’d say write your own version, so you can get full access to the items in it and do all this kind of stuff easily, rather than trying to bend my class to do all these things that I never planned it to do!


Yep, you’re right. I wrote a new FileTreeComponentEx for my purpose. This one also has find(String text) and findNext(String text) methods and scans the whole dir into memory.


I know this is an old thread, but I was wondering about the same thing. How did you solve it? I also want to start my own FileTreeComponent variant. :wink: