Package org.jdesktop.swingx.autocomplete
Class AutoCompleteDocument
- java.lang.Object
-
- org.jdesktop.swingx.autocomplete.AutoCompleteDocument
-
- All Implemented Interfaces:
Document
- Direct Known Subclasses:
AutoCompleteStyledDocument
public class AutoCompleteDocument extends Object implements Document
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
Fields Modifier and Type Field Description protected Documentdelegateprotected booleanstrictMatchingtrue, 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
Constructors Constructor Description AutoCompleteDocument(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDocumentListener(DocumentListener listener)voidaddUndoableEditListener(UndoableEditListener listener)protected DocumentcreateDefaultDocument()Creates the default backing document when no delegate is passed to this document.PositioncreatePosition(int offs)ElementgetDefaultRootElement()PositiongetEndPosition()intgetLength()ObjectgetProperty(Object key)Element[]getRootElements()PositiongetStartPosition()StringgetText(int offset, int length)voidgetText(int offset, int length, Segment txt)voidinsertString(int offs, String str, AttributeSet a)booleanisStrictMatching()Returns 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)voidremoveUndoableEditListener(UndoableEditListener listener)voidrender(Runnable r)
-
-
-
Field Detail
-
strictMatching
protected boolean strictMatching
true, if only items from the adaptors's list can be entered false, otherwise (selected item might not be in the adaptors's list)
-
delegate
protected final Document delegate
-
-
Constructor Detail
-
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
public AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching)
Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.- Parameters:
strictMatching- true, if only items from the adaptor's list should be allowed to be enteredadaptor- The adaptor that will be used to find and select matching items.
-
-
Method Detail
-
createDefaultDocument
protected Document createDefaultDocument()
Creates the default backing document when no delegate is passed to this document.- Returns:
- the default backing document
-
remove
public void remove(int offs, int len) throws BadLocationException- Specified by:
removein interfaceDocument- Throws:
BadLocationException
-
insertString
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException- Specified by:
insertStringin interfaceDocument- Throws:
BadLocationException
-
addDocumentListener
public void addDocumentListener(DocumentListener listener)
- Specified by:
addDocumentListenerin interfaceDocument
-
addUndoableEditListener
public void addUndoableEditListener(UndoableEditListener listener)
- Specified by:
addUndoableEditListenerin interfaceDocument
-
createPosition
public Position createPosition(int offs) throws BadLocationException
- Specified by:
createPositionin interfaceDocument- Throws:
BadLocationException
-
getDefaultRootElement
public Element getDefaultRootElement()
- Specified by:
getDefaultRootElementin interfaceDocument
-
getEndPosition
public Position getEndPosition()
- Specified by:
getEndPositionin interfaceDocument
-
getProperty
public Object getProperty(Object key)
- Specified by:
getPropertyin interfaceDocument
-
getRootElements
public Element[] getRootElements()
- Specified by:
getRootElementsin interfaceDocument
-
getStartPosition
public Position getStartPosition()
- Specified by:
getStartPositionin interfaceDocument
-
getText
public String getText(int offset, int length) throws BadLocationException
- Specified by:
getTextin interfaceDocument- Throws:
BadLocationException
-
getText
public void getText(int offset, int length, Segment txt) throws BadLocationException- Specified by:
getTextin interfaceDocument- Throws:
BadLocationException
-
putProperty
public void putProperty(Object key, Object value)
- Specified by:
putPropertyin interfaceDocument
-
removeDocumentListener
public void removeDocumentListener(DocumentListener listener)
- Specified by:
removeDocumentListenerin interfaceDocument
-
removeUndoableEditListener
public void removeUndoableEditListener(UndoableEditListener listener)
- Specified by:
removeUndoableEditListenerin interfaceDocument
-
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
-
-