org.jtheque.utils.ui
Class DocumentLengthFilter

java.lang.Object
  extended by javax.swing.text.DocumentFilter
      extended by org.jtheque.utils.ui.DocumentLengthFilter
Direct Known Subclasses:
DocumentLengthFilterAvert

public class DocumentLengthFilter
extends DocumentFilter

A document filter used to limit the length of a field.

Author:
Baptiste Wicht

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.DocumentFilter
DocumentFilter.FilterBypass
 
Constructor Summary
DocumentLengthFilter()
          Construct a new DocumentLengthFilter with a default maximum number of characters.
DocumentLengthFilter(int max)
          Construct a new DocumentLengthFilter with a maximum number of characters.
 
Method Summary
protected  int getMax()
          Return the maximum number of characters permitted in the document.
 void insertString(DocumentFilter.FilterBypass fb, int offset, String str, AttributeSet attrs)
           
 void replace(DocumentFilter.FilterBypass fb, int offset, int length, String str, AttributeSet attrs)
           
 
Methods inherited from class javax.swing.text.DocumentFilter
remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentLengthFilter

public DocumentLengthFilter()
Construct a new DocumentLengthFilter with a default maximum number of characters. By default, only 50 characters are accepted.


DocumentLengthFilter

public DocumentLengthFilter(int max)
Construct a new DocumentLengthFilter with a maximum number of characters.

Parameters:
max - The maximum number of characters permitted in the document.
Method Detail

insertString

public final void insertString(DocumentFilter.FilterBypass fb,
                               int offset,
                               String str,
                               AttributeSet attrs)
                        throws BadLocationException
Overrides:
insertString in class DocumentFilter
Throws:
BadLocationException

replace

public void replace(DocumentFilter.FilterBypass fb,
                    int offset,
                    int length,
                    String str,
                    AttributeSet attrs)
             throws BadLocationException
Overrides:
replace in class DocumentFilter
Throws:
BadLocationException

getMax

protected final int getMax()
Return the maximum number of characters permitted in the document.

Returns:
The number.


Copyright © 2010 JTheque. All Rights Reserved.