Package org.jdesktop.swingx.autocomplete
Class AutoCompleteDocument
- java.lang.Object
-
- org.jdesktop.swingx.autocomplete.AutoCompleteDocument
-
- All Implemented Interfaces:
javax.swing.text.Document,javax.swing.text.StyledDocument
public class AutoCompleteDocument extends java.lang.Object implements javax.swing.text.StyledDocumentA document that can be plugged into any JTextComponent to enable automatic completion. It finds and selects matching items using any implementation of the AbstractAutoCompleteAdaptor.
-
-
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, javax.swing.text.Document delegate)Creates a new AutoCompleteDocument for the given AbstractAutoCompleteAdaptor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDocumentListener(javax.swing.event.DocumentListener listener)javax.swing.text.StyleaddStyle(java.lang.String nm, javax.swing.text.Style parent)voidaddUndoableEditListener(javax.swing.event.UndoableEditListener listener)javax.swing.text.PositioncreatePosition(int offs)java.awt.ColorgetBackground(javax.swing.text.AttributeSet attr)javax.swing.text.ElementgetCharacterElement(int pos)javax.swing.text.ElementgetDefaultRootElement()javax.swing.text.PositiongetEndPosition()java.awt.FontgetFont(javax.swing.text.AttributeSet attr)java.awt.ColorgetForeground(javax.swing.text.AttributeSet attr)intgetLength()javax.swing.text.StylegetLogicalStyle(int p)javax.swing.text.ElementgetParagraphElement(int pos)java.lang.ObjectgetProperty(java.lang.Object key)javax.swing.text.Element[]getRootElements()javax.swing.text.PositiongetStartPosition()javax.swing.text.StylegetStyle(java.lang.String nm)java.lang.StringgetText(int offset, int length)voidgetText(int offset, int length, javax.swing.text.Segment txt)voidinsertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a)booleanisStrictMatching()Returns if only items from the adaptor's list should be allowed to be entered.voidputProperty(java.lang.Object key, java.lang.Object value)voidremove(int offs, int len)voidremoveDocumentListener(javax.swing.event.DocumentListener listener)voidremoveStyle(java.lang.String nm)voidremoveUndoableEditListener(javax.swing.event.UndoableEditListener listener)voidrender(java.lang.Runnable r)voidsetCharacterAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)voidsetLogicalStyle(int pos, javax.swing.text.Style s)voidsetParagraphAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)
-
-
-
Constructor Detail
-
AutoCompleteDocument
public AutoCompleteDocument(AbstractAutoCompleteAdaptor adaptor, boolean strictMatching, ObjectToStringConverter stringConverter, javax.swing.text.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
-
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 javax.swing.text.BadLocationException- Specified by:
removein interfacejavax.swing.text.Document- Throws:
javax.swing.text.BadLocationException
-
insertString
public void insertString(int offs, java.lang.String str, javax.swing.text.AttributeSet a) throws javax.swing.text.BadLocationException- Specified by:
insertStringin interfacejavax.swing.text.Document- Throws:
javax.swing.text.BadLocationException
-
addStyle
public javax.swing.text.Style addStyle(java.lang.String nm, javax.swing.text.Style parent)- Specified by:
addStylein interfacejavax.swing.text.StyledDocument
-
getBackground
public java.awt.Color getBackground(javax.swing.text.AttributeSet attr)
- Specified by:
getBackgroundin interfacejavax.swing.text.StyledDocument
-
getCharacterElement
public javax.swing.text.Element getCharacterElement(int pos)
- Specified by:
getCharacterElementin interfacejavax.swing.text.StyledDocument
-
getFont
public java.awt.Font getFont(javax.swing.text.AttributeSet attr)
- Specified by:
getFontin interfacejavax.swing.text.StyledDocument
-
getForeground
public java.awt.Color getForeground(javax.swing.text.AttributeSet attr)
- Specified by:
getForegroundin interfacejavax.swing.text.StyledDocument
-
getLogicalStyle
public javax.swing.text.Style getLogicalStyle(int p)
- Specified by:
getLogicalStylein interfacejavax.swing.text.StyledDocument
-
getParagraphElement
public javax.swing.text.Element getParagraphElement(int pos)
- Specified by:
getParagraphElementin interfacejavax.swing.text.StyledDocument
-
getStyle
public javax.swing.text.Style getStyle(java.lang.String nm)
- Specified by:
getStylein interfacejavax.swing.text.StyledDocument
-
removeStyle
public void removeStyle(java.lang.String nm)
- Specified by:
removeStylein interfacejavax.swing.text.StyledDocument
-
setCharacterAttributes
public void setCharacterAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)- Specified by:
setCharacterAttributesin interfacejavax.swing.text.StyledDocument
-
setLogicalStyle
public void setLogicalStyle(int pos, javax.swing.text.Style s)- Specified by:
setLogicalStylein interfacejavax.swing.text.StyledDocument
-
setParagraphAttributes
public void setParagraphAttributes(int offset, int length, javax.swing.text.AttributeSet s, boolean replace)- Specified by:
setParagraphAttributesin interfacejavax.swing.text.StyledDocument
-
addDocumentListener
public void addDocumentListener(javax.swing.event.DocumentListener listener)
- Specified by:
addDocumentListenerin interfacejavax.swing.text.Document
-
addUndoableEditListener
public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
- Specified by:
addUndoableEditListenerin interfacejavax.swing.text.Document
-
createPosition
public javax.swing.text.Position createPosition(int offs) throws javax.swing.text.BadLocationException- Specified by:
createPositionin interfacejavax.swing.text.Document- Throws:
javax.swing.text.BadLocationException
-
getDefaultRootElement
public javax.swing.text.Element getDefaultRootElement()
- Specified by:
getDefaultRootElementin interfacejavax.swing.text.Document
-
getEndPosition
public javax.swing.text.Position getEndPosition()
- Specified by:
getEndPositionin interfacejavax.swing.text.Document
-
getLength
public int getLength()
- Specified by:
getLengthin interfacejavax.swing.text.Document
-
getProperty
public java.lang.Object getProperty(java.lang.Object key)
- Specified by:
getPropertyin interfacejavax.swing.text.Document
-
getRootElements
public javax.swing.text.Element[] getRootElements()
- Specified by:
getRootElementsin interfacejavax.swing.text.Document
-
getStartPosition
public javax.swing.text.Position getStartPosition()
- Specified by:
getStartPositionin interfacejavax.swing.text.Document
-
getText
public java.lang.String getText(int offset, int length) throws javax.swing.text.BadLocationException- Specified by:
getTextin interfacejavax.swing.text.Document- Throws:
javax.swing.text.BadLocationException
-
getText
public void getText(int offset, int length, javax.swing.text.Segment txt) throws javax.swing.text.BadLocationException- Specified by:
getTextin interfacejavax.swing.text.Document- Throws:
javax.swing.text.BadLocationException
-
putProperty
public void putProperty(java.lang.Object key, java.lang.Object value)- Specified by:
putPropertyin interfacejavax.swing.text.Document
-
removeDocumentListener
public void removeDocumentListener(javax.swing.event.DocumentListener listener)
- Specified by:
removeDocumentListenerin interfacejavax.swing.text.Document
-
removeUndoableEditListener
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
- Specified by:
removeUndoableEditListenerin interfacejavax.swing.text.Document
-
render
public void render(java.lang.Runnable r)
- Specified by:
renderin interfacejavax.swing.text.Document
-
-