Package org.jdesktop.swingx.autocomplete
Class AutoCompleteDocument
java.lang.Object
org.jdesktop.swingx.autocomplete.AutoCompleteDocument
- All Implemented Interfaces:
Document
- Direct Known Subclasses:
AutoCompleteStyledDocument
A document that can be plugged into any JTextComponent to enable automatic completion.
It finds and selects matching items using any implementation of the AbstractAutoCompleteAdaptor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Documentprotected booleantrue, if only items from the adaptors's list can be entered false, otherwise (selected item might not be in the adaptors's list)Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty -
Constructor Summary
ConstructorsConstructorDescriptionAutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching) Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter) Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter, Document delegate) Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDocumentListener(DocumentListener listener) voidaddUndoableEditListener(UndoableEditListener listener) protected DocumentCreates the default backing document when no delegate is passed to this document.createPosition(int offs) intgetProperty(Object key) Element[]getText(int offset, int length) voidvoidinsertString(int offs, String str, AttributeSet a) booleanReturns if only items from the adaptor's list should be allowed to be entered.voidputProperty(Object key, Object value) voidremove(int offs, int len) voidremoveDocumentListener(DocumentListener listener) voidvoid
-
Field Details
-
strictMatching
protected boolean strictMatchingtrue, if only items from the adaptors's list can be entered false, otherwise (selected item might not be in the adaptors's list) -
delegate
-
-
Constructor Details
-
AutoCompleteDocument
public AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter, Document delegate) Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.- Parameters:
adaptor- The adaptor that will be used to find and select matching items.strictMatching- true, if only items from the adaptor's list should be allowed to be enteredstringConverter- the converter used to transform items to stringsdelegate- theDocumentdelegate backing this document
-
AutoCompleteDocument
public AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter) Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.- Parameters:
adaptor- The adaptor that will be used to find and select matching items.strictMatching- true, if only items from the adaptor's list should be allowed to be enteredstringConverter- the converter used to transform items to strings
-
AutoCompleteDocument
Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.- Parameters:
adaptor- The adaptor that will be used to find and select matching items.strictMatching- true, if only items from the adaptor's list should be allowed to be entered
-
-
Method Details
-
createDefaultDocument
Creates the default backing document when no delegate is passed to this document.- Returns:
- the default backing document
-
remove
- Specified by:
removein interfaceDocument- Throws:
BadLocationException
-
insertString
- Specified by:
insertStringin interfaceDocument- Throws:
BadLocationException
-
addDocumentListener
- Specified by:
addDocumentListenerin interfaceDocument
-
addUndoableEditListener
- Specified by:
addUndoableEditListenerin interfaceDocument
-
createPosition
- Specified by:
createPositionin interfaceDocument- Throws:
BadLocationException
-
getDefaultRootElement
- Specified by:
getDefaultRootElementin interfaceDocument
-
getEndPosition
- Specified by:
getEndPositionin interfaceDocument
-
getLength
public int getLength() -
getProperty
- Specified by:
getPropertyin interfaceDocument
-
getRootElements
- Specified by:
getRootElementsin interfaceDocument
-
getStartPosition
- Specified by:
getStartPositionin interfaceDocument
-
getText
- Specified by:
getTextin interfaceDocument- Throws:
BadLocationException
-
getText
- Specified by:
getTextin interfaceDocument- Throws:
BadLocationException
-
putProperty
- Specified by:
putPropertyin interfaceDocument
-
removeDocumentListener
- Specified by:
removeDocumentListenerin interfaceDocument
-
removeUndoableEditListener
- Specified by:
removeUndoableEditListenerin interfaceDocument
-
render
-
isStrictMatching
public boolean isStrictMatching()Returns if only items from the adaptor's list should be allowed to be entered.- Returns:
- if only items from the adaptor's list should be allowed to be entered
-