org.fife.ui
Class PickyDocumentFilter
java.lang.Object
javax.swing.text.DocumentFilter
org.fife.ui.PickyDocumentFilter
- Direct Known Subclasses:
- NumberDocumentFilter
- public abstract class PickyDocumentFilter
- extends javax.swing.text.DocumentFilter
A document filter that only allows certain characters to be entered.
Subclasses can simply override cleanseImpl(String), and either
remove invalid chars from the returned string, or return
null if there are any invalid characters, depending on how
they want the behavior of their text component.
- Version:
- 1.0
- Author:
- Robert Futrell
| Nested classes inherited from class javax.swing.text.DocumentFilter |
javax.swing.text.DocumentFilter.FilterBypass |
|
Method Summary |
protected java.lang.String |
cleanse(java.lang.String text)
"Cleans" the input text specified by passing it to
cleanseImpl(String). |
protected abstract java.lang.String |
cleanseImpl(java.lang.String text)
"Cleanses" the text to insert. |
void |
insertString(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
java.lang.String text,
javax.swing.text.AttributeSet attr)
|
void |
remove(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
int length)
|
void |
replace(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
int length,
java.lang.String text,
javax.swing.text.AttributeSet attr)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PickyDocumentFilter
public PickyDocumentFilter()
cleanseImpl
protected abstract java.lang.String cleanseImpl(java.lang.String text)
- "Cleanses" the text to insert. This can remove unsupported characters,
or cause the insert to do nothing by returning
null.
- Parameters:
text - The text to possibly insert.
- Returns:
- The "cleansed" text to insert.
- See Also:
cleanse(String)
cleanse
protected java.lang.String cleanse(java.lang.String text)
- "Cleans" the input text specified by passing it to
cleanseImpl(String). If it's "cleansed" in any way, a beep
is played.
- Parameters:
text - The text to possibly insert.
- Returns:
- The "cleansed" text to insert.
- See Also:
cleanseImpl(String)
insertString
public void insertString(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
java.lang.String text,
javax.swing.text.AttributeSet attr)
throws javax.swing.text.BadLocationException
- Throws:
javax.swing.text.BadLocationException
remove
public void remove(javax.swing.text.DocumentFilter.FilterBypass fb,
int offset,
int length)
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 text,
javax.swing.text.AttributeSet attr)
throws javax.swing.text.BadLocationException
- Throws:
javax.swing.text.BadLocationException