com.abstractics.utils.swing
Class CaseAndLengthDocumentFilter
java.lang.Object
javax.swing.text.DocumentFilter
com.abstractics.utils.swing.CaseAndLengthDocumentFilter
- public class CaseAndLengthDocumentFilter
- extends javax.swing.text.DocumentFilter
Implementation of a DocumentFilter that can place
length restrictions on the document, as well as force case (upper or lower)
if necessary.
- Version:
- $Id: CaseAndLengthDocumentFilter.java,v 1.2 2006/03/15 05:37:30 andyman99 Exp $
- Author:
- Andrew Lawrence, Copyright 2006 Abstractics, L.L.C., Licensed under the Apache
License, Version 2.0
| Nested classes inherited from class javax.swing.text.DocumentFilter |
javax.swing.text.DocumentFilter.FilterBypass |
|
Method Summary |
static void |
applyTo(javax.swing.text.JTextComponent comp,
java.lang.String forceCase,
int maxLength)
Convenience method to make the necessary adjustments to the given
JTextComponent to apply a CaseAndLengthDocumentFilter. |
void |
insertString(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
java.lang.String string,
javax.swing.text.AttributeSet attr)
|
void |
replace(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
int length,
java.lang.String string,
javax.swing.text.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 |
ANYCASE
public static final java.lang.String ANYCASE
- See Also:
- Constant Field Values
UPPERCASE
public static final java.lang.String UPPERCASE
- See Also:
- Constant Field Values
LOWERCASE
public static final java.lang.String LOWERCASE
- See Also:
- Constant Field Values
CaseAndLengthDocumentFilter
public CaseAndLengthDocumentFilter(java.lang.String forceCase)
- Parameters:
forceCase - One of three values: ANYCASE, UPPERCASE,
or {@link #LOWERCASE)
- Throws:
java.lang.IllegalArgumentException - Thrown if the forceCase parameter is not a valid value
CaseAndLengthDocumentFilter
public CaseAndLengthDocumentFilter(int maxLength)
- Parameters:
maxLength - Maximumm length of text allowed - or zero to not enforce a
maximum length
- Throws:
java.lang.IllegalArgumentException - Thrown if the forceCase parameter is not a valid value
CaseAndLengthDocumentFilter
public CaseAndLengthDocumentFilter(java.lang.String forceCase,
int maxLength)
- Parameters:
forceCase - One of three values: ANYCASE, UPPERCASE,
or {@link #LOWERCASE)maxLength - Maximumm length of text allowed - or zero to not enforce a
maximum length
- Throws:
java.lang.IllegalArgumentException - Thrown if the forceCase parameter is not a valid value
applyTo
public static void applyTo(javax.swing.text.JTextComponent comp,
java.lang.String forceCase,
int maxLength)
- Convenience method to make the necessary adjustments to the given
JTextComponent to apply a
CaseAndLengthDocumentFilter. This
method makes sure that the document being used by the JTextComponent is
an instance of javax.swing.text.AbstractDocument and then
takes that document and calls setDocumentFilter() with a
new instance of CaseAndLengthDocumentFilter.
- Parameters:
comp - JTextComponent to add the DocumentFilter toforceCase - One of three values: ANYCASE, UPPERCASE,
or {@link #LOWERCASE)maxLength - Maximumm length of text allowed - or zero to not enforce a
maximum length
insertString
public void insertString(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
java.lang.String string,
javax.swing.text.AttributeSet attr)
throws javax.swing.text.BadLocationException
- Throws:
javax.swing.text.BadLocationException
replace
public void replace(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
int length,
java.lang.String string,
javax.swing.text.AttributeSet attrs)
throws javax.swing.text.BadLocationException
- Throws:
javax.swing.text.BadLocationException