Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation in Swing Application

 
manisha ankolekar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic