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 in Swing Application Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 35438
    
    9
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.


Android appsImageJ pluginsJava web charts
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 8562

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.


[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation in Swing Application
 
Similar Threads
ajax and struts2
How to set data format of JTextField ??
How to stop Values being cleared JTextField in non-english locales
How to stop Values being cleared JTextField in non-english locales
Input Textfield Background Color When the Cursor Is There