Class JTextFieldFilterDocument

All Implemented Interfaces:
Document, Serializable

public class JTextFieldFilterDocument
extends JTextFieldMaxCharsDocument

This class is a special subclass of the JTextFieldMaxCharsDocument class. It checks to make sure characters being inserted into the document (and therefor the text field) are contained in the filter string. If we are using the class in include mode and they are not, they are discarded. If we are using the class in exclude mode and they are, they are discarded.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.text.AbstractDocument
AbstractDocument.AbstractElement, AbstractDocument.AttributeContext, AbstractDocument.BranchElement, AbstractDocument.Content, AbstractDocument.DefaultDocumentEvent, AbstractDocument.ElementEdit, AbstractDocument.LeafElement
Fields inherited from class bill.util.gui.JTextFieldMaxCharsDocument
_maxChars, _shiftFocusWhenFull, _textField
Fields inherited from class javax.swing.text.PlainDocument
lineLimitAttribute, tabSizeAttribute
Fields inherited from class javax.swing.text.AbstractDocument
BAD_LOCATION, BidiElementName, ContentElementName, ElementNameAttribute, listenerList, ParagraphElementName, SectionElementName
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
Constructor Summary
JTextFieldFilterDocument(JTextFieldFilterInterface textField)
          Creates a new class instance with the specified filter that uses include mode and limits the number of characters entered.
Method Summary
 String getFilter()
          Retrieves the current filter string value.
 void insertString(int offs, String str, AttributeSet a)
          Called when a character (or characters) are added to the document.
 boolean isInclude()
          Retrieves the include mode for this instance.
 void setFilter(String filter)
          Sets the filter string to the specified value.
 void setInclude(boolean include)
          Sets the include mode of the filter.
Methods inherited from class bill.util.gui.JTextFieldMaxCharsDocument
getMaxChars, isShiftFocusWhenFull, setMaxChars, setShiftFocusWhenFull
Methods inherited from class javax.swing.text.PlainDocument
createDefaultRoot, getDefaultRootElement, getParagraphElement, insertUpdate, removeUpdate
Methods inherited from class javax.swing.text.AbstractDocument
addDocumentListener, addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeDocumentListener, removeUndoableEditListener, render, setAsynchronousLoadPriority, setDocumentProperties, writeLock, writeUnlock
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public JTextFieldFilterDocument(JTextFieldFilterInterface textField)
Creates a new class instance with the specified filter that uses include mode and limits the number of characters entered.
textField - The text field that we are putting the filter on.
Method Detail


public void setFilter(String filter)
Sets the filter string to the specified value. We do not allow the filter to be set to null so if the user passes this in we set the filter to an empty string.
filter - String to set the filter to.


public String getFilter()
Retrieves the current filter string value.
The filter string value.


public void setInclude(boolean include)
Sets the include mode of the filter. If the include mode is true then characters entered that are in the filter string are kept and others are dropped, if false then vice versa.
include - Value to set include mode to.


public boolean isInclude()
Retrieves the include mode for this instance.
true if we are using include mode, false if we are using exclude mode.


public void insertString(int offs,
                         String str,
                         AttributeSet a)
                  throws BadLocationException
Called when a character (or characters) are added to the document. Applies the filter criteria and updates the document as appropriate.
insertString in class JTextFieldMaxCharsDocument
offs - The starting offset to insert at (>=0).
str - The string to insert, does nothing with null/empty strings.
a - The attributes for the inserted content.