| |
|
| java.lang.Object com.jidesoft.swing.Searchable com.jidesoft.swing.TreeSearchable
TreeSearchable | public class TreeSearchable extends Searchable implements TreeModelListener,PropertyChangeListener(Code) | | TreeSearchable is an concrete implementation of
Searchable that enables the search function in JTree.
It's very simple to use it. Assuming you have a JTree, all you need to do is to
call
JTree tree = ....;
TreeSearchable searchable = new TreeSearchable(tree);
Now the JTree will have the search function.
There is very little customization you need to do to TreeSearchable. The only thing you might
need is when the element in the JTree needs a special conversion to convert to string. If so, you can overide
convertElementToString() to provide you own algorithm to do the conversion.
JTree tree = ....;
TreeSearchable searchable = new TreeSearchable(tree) {
protected String convertElementToString(Object object) {
...
}
};
Additional customization can be done on the base Searchable class such as background and foreground color, keystrokes,
case sensitivity,
|
convertElementToString | protected String convertElementToString(Object object)(Code) | | Converts the element in JTree to string. The element by default is TreePath.
The returned value will be toString() of the last path component in the TreePath.
Parameters: object - the string representing the TreePath in the JTree. |
getElementCount | protected int getElementCount()(Code) | | |
getSelectedIndex | protected int getSelectedIndex()(Code) | | |
getTreePathes | protected List<TreePath> getTreePathes()(Code) | | Gets the cached tree pathes list. If it has never been cached before, this method
will create the cache.
Tree pathes list is only used when recursive attriubute is true.
the tree pathes list. |
isRecursive | public boolean isRecursive()(Code) | | Checks if the searchable is recursive.
true if searchabe is recursive. |
populateTreePaths | protected void populateTreePaths()(Code) | | Recursively go through the tree to populate the tree pathes into a list and cache them.
Tree pathes list is only used when recursive attriubute is true.
|
resetTreePathes | protected void resetTreePathes()(Code) | | Reset the cached tree pathes list.
Tree pathes list is only used when recursive attriubute is true.
|
setRecursive | public void setRecursive(boolean recursive)(Code) | | Sets the recursive attribute.
If TreeSearchable is recursive, it will all tree nodes including those which are not visible
to find the matching node. Obviously, if your tree has unlimited number of tree nodes
or a potential huge number of tree nodes (such as a tree to represent file system),
the recursive attribute should be false. To avoid this potential problem in this case, we default it to false.
Parameters: recursive - |
setSelectedIndex | protected void setSelectedIndex(int index, boolean incremental)(Code) | | |
uninstallListeners | public void uninstallListeners()(Code) | | |
|
|
|