Use PlainDocument to set the max limit. Here is a rough sketch :
public class JTextFieldLimit extends PlainDocument {
public void insertString( int offset, String str, AttributeSet attr ) throws BadLocationException {
super.insertString(offset, str, attr);
}
}