This came about as a need for a project I was working on. I couldn’t find a nice free open source implementation out there. So I wrote this one. The goal was to write something that was very easy to use, and required almost no additional coding or understanding of the inner workings of the widget.
- Works with any pre-loaded JTree
- Installs easily in one line of code : SearchableJTree.makeSearchable(JTree tree);
- Pops up when user types a key when the JTree has focus. Hides away when user presses ESC or ENTER
- Search results are updated in realtime as user types each character.
Whats new in v1.1:
- Search UI is now customizable. Change colors, positioning and transparency
- Keyboard UP and DOWN arrow keys can now be used to cycle through the matches one at a time.
- search bar now offset from the bottom/top by the JTree row height. This helps in viewing the matches that lie at the edges of the JTree viewport.
- Modified the demo program to showcase all features.
- Better separation of UI and business logic in the code.