bill.util.gui
Class JTextFieldFilterDocument

java.lang.Object
  |
  +--javax.swing.text.AbstractDocument
        |
        +--javax.swing.text.PlainDocument
              |
              +--bill.util.gui.JTextFieldMaxCharsDocument
                    |
                    +--bill.util.gui.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

JTextFieldFilterDocument

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

setFilter

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.
Parameters:
filter - String to set the filter to.

getFilter

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

setInclude

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.
Parameters:
include - Value to set include mode to.

isInclude

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

insertString

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.
Overrides:
insertString in class JTextFieldMaxCharsDocument
Parameters:
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.