File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes validation 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 "validation" Watch "validation" New topic
Author

validation

Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83

Hello does anyone know how can i validate a jtextfield in swing .Example i want to have only digits 5 digits and not empty.
I have read about Hibernate validator but i don't know how to use it any examples?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

If you're not otherwise using Hibernate just use a DocumentFilter.


luck, db
There are no new questions, but there may be new answers.
Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
Darryl Burke wrote:If you're not otherwise using Hibernate just use a DocumentFilter.

can you explain what you mean?I have seen DocumentFilter.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2251
    
  47
If you want to force the user to enter exactly 5 digits then look at JFormattedTextField.
Alternatively you can set an input verifier to check what a user has entered and stop focus shifting to the next component if the input is invalid - see javax.swing.InputVerifier
Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
Tony Docherty wrote:If you want to force the user to enter exactly 5 digits then look at JFormattedTextField.
Alternatively you can set an input verifier to check what a user has entered and stop focus shifting to the next component if the input is invalid - see javax.swing.InputVerifier


Thanks i will try them
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1077
    
  10

Also, be sure to checkout the example from our SwingFAQ: example


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Georgios Chatziefstratiou
Ranch Hand

Joined: May 26, 2012
Posts: 83
Ranganathan Kaliyur Mannar wrote:Also, be sure to checkout the example from our SwingFAQ: example

Thanks you both very helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validation