Class MaxLengthDocumentFilter
- java.lang.Object
-
- javax.swing.text.DocumentFilter
-
- org.openstreetmap.josm.gui.tagging.ac.MaxLengthDocumentFilter
-
public class MaxLengthDocumentFilter extends DocumentFilter
ADocumentFilter
to limit the text length in the editor.- Since:
- 18221
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.text.DocumentFilter
DocumentFilter.FilterBypass
-
-
Constructor Summary
Constructors Constructor Description MaxLengthDocumentFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr)
private boolean
mustInsertOrReplace(DocumentFilter.FilterBypass fb, int length, String string, AttributeSet attr)
void
replace(DocumentFilter.FilterBypass fb, int offset, int length, String string, AttributeSet attr)
void
setMaxLength(int length)
Sets the maximum text length.-
Methods inherited from class javax.swing.text.DocumentFilter
remove
-
-
-
-
Constructor Detail
-
MaxLengthDocumentFilter
public MaxLengthDocumentFilter()
-
-
Method Detail
-
setMaxLength
public void setMaxLength(int length)
Sets the maximum text length.- Parameters:
length
- the maximum no. of charactes allowed in this document. -1 to disable
-
insertString
public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException
- Overrides:
insertString
in classDocumentFilter
- Throws:
BadLocationException
-
replace
public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String string, AttributeSet attr) throws BadLocationException
- Overrides:
replace
in classDocumentFilter
- Throws:
BadLocationException
-
mustInsertOrReplace
private boolean mustInsertOrReplace(DocumentFilter.FilterBypass fb, int length, String string, AttributeSet attr)
-
-