Package com.jidesoft.swing
Class SearchableUtils
java.lang.Object
com.jidesoft.swing.SearchableUtils
Utility class to make component searchable. It's very easy to use this class. In order to make a component, all you
need to do is to call
SearchableUtils.installSearchable(component);
The component could be a JList, JTree or JTable. If you need to further customize some attributes of Searchable, you
can assign a variable that returns from installSearchable().
Searchable searchable = SearchableUtils.installSearchable(component);
// further configure it
searchable.setCaseSensitive(true);
// ...
Usually you don't need to uninstall the searchable from the component. But if for some reason, you need to disable
the searchable feature of the component, you can call uninstallSearchable().
Searchable searchable = SearchableUtils.installSearchable(component);
// ...
// Now disable it
SearchableUtils.uninstallSearchable(searchable);
There is a small trick that you should know. JTree and JList implemented partially the quick search feature so that
when you type in the first character, it will jump to the first occurrence. This feature sometimes conflicts with the
Searchable we provided. So it'd better if you disable the JTree or JList default feature by creating JTree and JList
with getNextMatch method overridden. See below
JTree tree = new JTree(...) {
public TreePath getNextMatch(String prefix, int startingRow, Position.Bias bias) {
return null;
}
};
JList list = new JList(...){
public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
return -1;
}
};
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ComboBoxSearchable
installSearchable
(JComboBox combobox) Installs the searchable function onto a JComboBox.static ListSearchable
installSearchable
(JList list) Installs the searchable function onto a JList.static TableSearchable
installSearchable
(JTable table) Installs the searchable function onto a JTable.static TreeSearchable
installSearchable
(JTree tree) Installs the searchable function onto a JTree.static TextComponentSearchable
installSearchable
(JTextComponent textComponent) Installs the searchable function onto a JTextComponent.static void
uninstallSearchable
(Searchable searchable) Uninstall the searchable that was installed to a componentstatic void
uninstallSearchable
(JComponent component) Uninstall the searchable that was installed to a component
-
Constructor Details
-
SearchableUtils
public SearchableUtils()
-
-
Method Details
-
installSearchable
Installs the searchable function onto a JTree.- Parameters:
tree
- the JTree to install searchable- Returns:
- A TreeSearchable
-
installSearchable
Installs the searchable function onto a JTable.- Parameters:
table
- the JTable to install searchable- Returns:
- A TableSearchable
-
installSearchable
Installs the searchable function onto a JList.- Parameters:
list
- the JList to install searchable- Returns:
- A ListSearchable
-
installSearchable
Installs the searchable function onto a JComboBox.- Parameters:
combobox
- the combo box to install searchable- Returns:
- A ComboBoxSearchable
-
installSearchable
Installs the searchable function onto a JTextComponent.- Parameters:
textComponent
- the text component to install searchable- Returns:
- A TextComponentSearchable
-
uninstallSearchable
Uninstall the searchable that was installed to a component- Parameters:
searchable
- the searchable.
-
uninstallSearchable
Uninstall the searchable that was installed to a component- Parameters:
component
- the component that has a searchable installed.
-