aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Validation in Swing Application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Validation in Swing Application" Watch "Validation in Swing Application" New topic
Author

Validation in Swing Application

manisha ankolekar
Greenhorn

Joined: Nov 26, 2006
Posts: 10
Hi........I am working on my project.I want to validate value entered in TextField is year(using YYYY/Mon/DD format).how I should do it.

Also how to validate input enterec in Textfield is Number

Pls help.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
There's an example of checking for numbers in the Code Barn: http://faq.javaranch.com/java/NumericTextField

Checking for a valid date would be similar, but would involve a more complex regular expression.


Ping & DNS - my free Android networking tools app
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Originally posted by manisha ankolekar:
Hi........I am working on my project.I want to validate value entered in TextField is year(using YYYY/Mon/DD format).how I should do it.

Also how to validate input enterec in Textfield is Number

Pls help.


Any particular reason why you must use a JTextField as a date editor component? This is akin to living in the stone age (Just kidding).

You might want to consider the JSpinner which accepts a SpinnerDateModel.
JSpinner tutorials can be found here
Also you might want to take a look at this cool component.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation in Swing Application