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.
The moose likes Swing / AWT / SWT and the fly likes validate JTextfield input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "validate JTextfield input" Watch "validate JTextfield input" New topic

validate JTextfield input

Sarone Thach
Ranch Hand

Joined: Jun 25, 2003
Posts: 89
Does anyone know of an easy way of validating the JTextfield input. I would like to only permit numbers in the JTextfield, and deleting any character strings the user have entered. If possible, preventing the string to be displayed at all.
thanks in advanced for your help.
Sainath Veepuri
Ranch Hand

Joined: Sep 25, 2003
Posts: 49
hi sarone,
write a utility class which extends javax.swing.text.PlainDocument and override the insertString method and define it the way you want.Finally set the document for ur jtextfield.
I agree. Here's the link:
subject: validate JTextfield input