I googled a bit around to find a solution for my problem "limit number of chars in a JTextField". So the code isn't the problem, but you have (at least) 3 different ways of doing this:
1) an InputVerifier 2) create a specific PlainDocument 3) create a specific DocumentFilter 4) maybe something i didn't find on google
Which is the best solution? Any guidelines in which one to use? Maybe one i must not use because it's really bad...
2 remarks though:
- in the Javadoc of JTextField a similar example is handled by creating a specific PlainDocument. so this should be altered
- if you want to set your FilterDocument, you have to do it like this (imho that's a bit messy):