wood burning stoves 2.0*
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
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: 41108
    
  45
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: 10170
    
    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!]
 
wood burning stoves
 
subject: Validation in Swing Application
 
Similar Threads
How to stop Values being cleared JTextField in non-english locales
Input Textfield Background Color When the Cursor Is There
How to stop Values being cleared JTextField in non-english locales
How to set data format of JTextField ??
ajax and struts2