org.jdesktop.swingx.autocomplete
Class AutoCompleteDocument
java.lang.Object
javax.swing.text.AbstractDocument
javax.swing.text.PlainDocument
org.jdesktop.swingx.autocomplete.AutoCompleteDocument
- All Implemented Interfaces:
- Serializable, Document
public class AutoCompleteDocument
- extends PlainDocument
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.
- See Also:
- Serialized Form
Method Summary |
void |
insertString(int offs,
String str,
AttributeSet a)
Inserts some content into the document. |
boolean |
isStrictMatching()
Returns if only items from the adaptor's list should be allowed to be entered. |
void |
remove(int offs,
int len)
Removes some content from the document. |
Methods inherited from class javax.swing.text.AbstractDocument |
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, postRemoveUpdate, putProperty, readLock, readUnlock, removeDocumentListener, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
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
remove
public void remove(int offs,
int len)
throws BadLocationException
- Description copied from class:
javax.swing.text.AbstractDocument
- Removes some content from the document.
Removing content causes a write lock to be held while the
actual changes are taking place. Observers are notified
of the change on the thread that called this method.
This method is thread safe, although most Swing methods
are not. Please see
Threads
and Swing for more information.
- Specified by:
remove
in interface Document
- Overrides:
remove
in class AbstractDocument
- Parameters:
offs
- the starting offset >= 0len
- the number of characters to remove >= 0
- Throws:
BadLocationException
- the given remove position is not a valid
position within the document- See Also:
Document.remove(int, int)
insertString
public void insertString(int offs,
String str,
AttributeSet a)
throws BadLocationException
- Description copied from class:
javax.swing.text.PlainDocument
- Inserts some content into the document.
Inserting content causes a write lock to be held while the
actual changes are taking place, followed by notification
to the observers on the thread that grabbed the write lock.
This method is thread safe, although most Swing methods
are not. Please see
Threads
and Swing for more information.
- Specified by:
insertString
in interface Document
- Overrides:
insertString
in class PlainDocument
- Parameters:
offs
- the starting offset >= 0str
- the string to insert; does nothing with null/empty stringsa
- the attributes for the inserted content
- Throws:
BadLocationException
- the given insert position is not a valid
position within the document- See Also:
Document.insertString(int, java.lang.String, javax.swing.text.AttributeSet)