This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
You can create a customized Textfield extends JTextField. In the constructor use the class which extends PlainDocument.
By overriding the method insertString in PlainDocument interface you can allow the user to enter only the specified number of character.