This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
The easiest way to validate data in a JTextField is to us a PlainDocument, this can be used to prevent certain characters from being entered and also the length. Look at the API at the PlainDocument class, and extend it and you can create a NumericDocument, then extend the JTextField and create a NumericTextField. Or check isDigit when you do #2. I think #2 is better because it won't fire as much as #1 will.