public class JAutoComplete extends java.lang.Object implements AutoComplete
setOpacity(float): the opacity of the Popup WindowacceptDuplicates(boolean): true if the dictionnary accept duplicates
JTextField tf = new JTextField(10);
AutoComplete2 autoCompleter = new AutoComplete2(tf);
autoCompleter.setOpacity(0.9f);
//add the dictionary
autoCompleter.addToDictionary("hello");
autoCompleter.addToDictionary("highlight");
autoCompleter.addToDictionary("cruel world");
autoCompleter.addToDictionary("war");
autoCompleter.addToDictionary("wording");
autoCompleter.addToDictionary("world");
| Modifier and Type | Class and Description |
|---|---|
class |
JAutoComplete.SuggestedHit
The Label used for the Suggested Hits.
|
| Modifier and Type | Field and Description |
|---|---|
protected javax.swing.text.JTextComponent |
textComponent
The text component.
|
| Constructor and Description |
|---|
JAutoComplete(javax.swing.text.JTextComponent textComponent)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acceptDuplicates(boolean acceptDuplicates)
Set if the dictionnary accept duplicates.
|
void |
addAdditionalSearchSuggestion(java.lang.String typedText)
Add the additional search text suggestion in the popup Window.
|
void |
addAdditionalSearchText(java.lang.String text)
Add the additional search item in the popup.
|
void |
addAutoCompleteListener(AutoCompleteListener l)
Add an JAutoComplete listener.
|
boolean |
addCategory(AutoCompleteDictionary.Category category)
Add a category to the dictionary.
|
void |
addCategory(java.lang.String category)
Add a category to the dictionary.
|
void |
addCategoryToSuggestions(AutoCompleteDictionary.Category category)
Add a category to the list of suggestions in the Popup Window.
|
boolean |
addItemToSuggestions(java.lang.String category,
AutoCompleteDictionary.Item item)
Add a category to the list of suggestions in the Popup Window.
|
void |
addSearchTextListener(AdditionalSearchListener l)
Add an containing text listener.
|
void |
addToDictionary(AutoCompleteDictionary.Item item)
Add an item to the dictionary to use for the autoComplete.
|
void |
addToDictionary(java.lang.String word)
Add a word to the dictionary to use for the autoComplete.
|
void |
addToDictionary(java.lang.String category,
AutoCompleteDictionary.Item item)
Add an item to the dictionary to use for the autoComplete.
|
void |
addToDictionary(java.lang.String category,
java.lang.String word)
Add a word to the dictionary to use for the autoComplete.
|
java.util.List<AutoCompleteListener> |
getAutoCompleteListeners()
Return the list of JAutoComplete listeners.
|
java.util.List<AdditionalSearchListener> |
getContainingTextListeners()
Return the list of containing text listeners.
|
AutoCompleteDictionary |
getDictionary()
Return the dictionnary used for the Autocompletion.
|
float |
getOpacity()
Return the Popup Window opacity.
|
protected java.awt.Color |
getPopUpBackgroundColor()
Return the background color of the suggested hits panel.
|
protected java.awt.Color |
getPopUpBorderColor()
Return the borded color of the suggested hits panel.
|
int |
getResultsLimit()
Return the results limits.
|
protected java.awt.Color |
getSuggestedHitFocusedColor()
Return the background color of the focused suggested hit.
|
protected java.awt.Color |
getSuggestedHitTextColor()
Return the color of the suggested hits text.
|
java.lang.String |
getText()
Return the text component text.
|
javax.swing.text.JTextComponent |
getTextComponent()
Return the text component.
|
boolean |
hasAdditionalSearchItem()
Return true if there is an additional search item in the popup.
|
boolean |
hasDefaultCategory()
Return true if the dictionnary uses only the default category.
|
boolean |
isAcceptingDuplicates()
Return true if the dictionnary accept duplicates.
|
void |
removeAutoCompleteListener(AutoCompleteListener l)
Removes an JAutoComplete listener.
|
void |
removeContainingTextListener(AdditionalSearchListener l)
Removes a containing text listener.
|
void |
resetDictionary()
Reset the Dictionnary to use for the autoComplete.
|
void |
setDictionnary(AutoCompleteDictionary dictionary)
Set the dictionnary used for the Autocompletion.
|
void |
setMaximumPopupSize(int maxWidth,
int maxHeight)
Set the maximum width and height of the Popup.
|
void |
setOpacity(float opacity)
Set the Popup Window opacity.
|
void |
setResultsLimit(int limit)
Set the results limits.
|
protected void |
updatePopupSize(int width,
int height)
Update the PopUp Size.
|
protected javax.swing.text.JTextComponent textComponent
public JAutoComplete(javax.swing.text.JTextComponent textComponent)
textComponent - the text Componentpublic void setMaximumPopupSize(int maxWidth,
int maxHeight)
setMaximumPopupSize in interface AutoCompletemaxWidth - the maximum width of the PopupmaxHeight - the maximum height of the Popuppublic void setOpacity(float opacity)
opacity - the opacitypublic float getOpacity()
public boolean hasDefaultCategory()
public void acceptDuplicates(boolean acceptDuplicates)
acceptDuplicates - true if the dictionnary accept duplicatespublic boolean isAcceptingDuplicates()
public void setResultsLimit(int limit)
limit - the results limitspublic int getResultsLimit()
getResultsLimit in interface AutoCompleteprotected java.awt.Color getSuggestedHitTextColor()
protected java.awt.Color getSuggestedHitFocusedColor()
protected java.awt.Color getPopUpBackgroundColor()
protected java.awt.Color getPopUpBorderColor()
public void addAutoCompleteListener(AutoCompleteListener l)
l - the listenerpublic void removeAutoCompleteListener(AutoCompleteListener l)
l - the listenerpublic java.util.List<AutoCompleteListener> getAutoCompleteListeners()
public void addSearchTextListener(AdditionalSearchListener l)
l - the listenerpublic void removeContainingTextListener(AdditionalSearchListener l)
l - the listenerpublic java.util.List<AdditionalSearchListener> getContainingTextListeners()
public final java.lang.String getText()
public void addCategoryToSuggestions(AutoCompleteDictionary.Category category)
AutoCompleteEngine used for the
search with a Popup Window.addCategoryToSuggestions in interface AutoCompletecategory - the categorypublic boolean addItemToSuggestions(java.lang.String category,
AutoCompleteDictionary.Item item)
AutoCompleteEngine used for the
search with a Popup Window.addItemToSuggestions in interface AutoCompletecategory - the category nameitem - the Itempublic void addAdditionalSearchSuggestion(java.lang.String typedText)
addAdditionalSearchSuggestion in interface AutoCompletetypedText - the typed textpublic void addAdditionalSearchText(java.lang.String text)
addAdditionalSearchText in interface AutoCompletetext - the text for the additional search itempublic boolean hasAdditionalSearchItem()
hasAdditionalSearchItem in interface AutoCompleteprotected final void updatePopupSize(int width,
int height)
width - the width of the elementheight - the height of the elementpublic void resetDictionary()
resetDictionary in interface AutoCompletepublic AutoCompleteDictionary getDictionary()
getDictionary in interface AutoCompletepublic void setDictionnary(AutoCompleteDictionary dictionary)
setDictionnary in interface AutoCompletedictionary - the dictionnarypublic boolean addCategory(AutoCompleteDictionary.Category category)
addCategory in interface AutoCompletecategory - the categorypublic void addCategory(java.lang.String category)
addCategory in interface AutoCompletecategory - the category namepublic void addToDictionary(java.lang.String word)
addToDictionary in interface AutoCompleteword - the wordpublic void addToDictionary(AutoCompleteDictionary.Item item)
addToDictionary in interface AutoCompleteitem - the itempublic void addToDictionary(java.lang.String category,
java.lang.String word)
addToDictionary in interface AutoCompletecategory - the item categoryword - the wordpublic void addToDictionary(java.lang.String category,
AutoCompleteDictionary.Item item)
addToDictionary in interface AutoCompletecategory - the item categoryitem - the itempublic javax.swing.text.JTextComponent getTextComponent()
Copyright © 2016-2024 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence