Please have a look at the following code.
import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.*; import javax.swing.text.AbstractDocum
You should make your own class that checks whether you gave more input than the maximum allowed length: See an example on http://www.java2s.com/Tutorial/Java/0240__Swing/LimitJTextFieldinputtoamaximumlength.htm.