Read in the tutorial how to use custom editors:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
Then see the example in the tutorial how to limit the length of characters entered into a text field using a DocumentFilter:
http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter