In text field more than 10 characters na, it has to show an error. For that i used document filter:
JTextField field = (JTextField) txtFld;
AbstractDocument document = (AbstractDocument) field.getDocument();
document.setDocumentFilter(new DocumentSizeAndUppercaseFilter(10));
So this is my document filter coding. I registered the textfield through document filter. But nothing has happening here. How to use document filter?
DocumentSizeAndUppercaseFilter class which has the error msg.
Without seeing the code for
DocumentSizeAndUppercaseFilterI would suspect that you havn’t implemented (/override) theDocumentFilter‘sreplacemethod:Screenshot from the code below:
Example implementation of
DocumentSizeAndUppercaseFilter:Example
main: