Class JComboBoxConfigurableLookUp.PlainDocumentTextFormatter
- All Implemented Interfaces:
Serializable,Document
- Enclosing class:
JComboBoxConfigurableLookUp
Inner class that inherits of the class PlainDocument, and is used for manipulate the textWritten that has the document of the editor of this component.
This class is also optimized for items look up process.
- Author:
- Pablo Piqueras Bartolomé (p_queras@hotmail.com)
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement -
Field Summary
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttributeFields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementNameFields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidThis method makes some initialize operations.voidinsertString(int offs, String str, AttributeSet a) voidremove(int offs, int len) voidreplace(int offset, int length, String text, AttributeSet attrs) protected voidSets a reference of this component.voidupdateCaretPosition(int position) Updates the position of the caret in theComboBoxEditorof this component.voidUpdates the color of the text in this document.voidUpdates the color of the text in theComboBoxEditorof this component, and rings a beep if there is no item.Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdateMethods 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, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
-
Constructor Details
-
PlainDocumentTextFormatter
public PlainDocumentTextFormatter()Default Constructor.
-
-
Method Details
-
initialize
protected void initialize()This method makes some initialize operations.
-
setJComboBoxReference
Sets a reference of this component.
- Parameters:
comboBox- A reference to the class that contains this.
-
insertString
- Specified by:
insertStringin interfaceDocument- Overrides:
insertStringin classPlainDocument- Throws:
BadLocationException
-
replace
public void replace(int offset, int length, String text, AttributeSet attrs) throws BadLocationException - Overrides:
replacein classAbstractDocument- Throws:
BadLocationException
-
remove
- Specified by:
removein interfaceDocument- Overrides:
removein classAbstractDocument- Throws:
BadLocationException
-
updateTextColorAndRingBeep
public void updateTextColorAndRingBeep()Updates the color of the text in the
ComboBoxEditorof this component, and rings a beep if there is no item.- Text in red color: if no item matches with the text written according the
ILookUpagent. - Text in black color: if there is at least one item matches with the text written according the
ILookUpagent.
- Text in red color: if no item matches with the text written according the
-
updateCaretPosition
public void updateCaretPosition(int position) Updates the position of the caret in the
ComboBoxEditorof this component.- Parameters:
position- the new position of the caret.
-
updateOnlyTextColor
public void updateOnlyTextColor()Updates the color of the text in this document.
Sets text to red color if there is no item in the visible list that the look up agent returned with that text and the items of the dataModel, and, being enabled the second color in the configuration the the
JcomboBoxConfigurableLookUpagent. Otherwise, the foreground color of the text will be black.This method disables the beep during the process of updating the color of the text, and restores it after.
-