Link to home
Start Free TrialLog in
Avatar of rich420
rich420

asked on

JTextField

Is there a type of Text Entry Field that only allows the user to enter numeric data, such as dates?
Avatar of glottis
glottis
Flag of Pakistan image

if u use jdk1.4 then there is JFormatTextField
else you can search for such components, or if u are a genius you can make one :P
Avatar of rich420
rich420

ASKER

thanks for that, but I couldn't find a JFormatTextField, or am I using the wrong version.

Did you mean JFormattedTextField? If so, How do I use JFormattedTextField to accept dates only?

Could I have a small example or explanation
glottis is right.

for date u can use thre list box for dd, mm and yyyy and a script for validation
Avatar of rich420

ASKER

I am not allowed to have any validation scripts, because invalid characters should not even be allowed to be typed into the text field.
u r right, but i haven't any more idea
JFormattedTextField ftf = new JFormattedTextField();
ftf.setValue(new Date()); // for dates

ftf.setValue(new Integer(1)); // for numbers

if u study the JFormattedTextField u can add poissibly any type of format
ASKER CERTIFIED SOLUTION
Avatar of hamish5
hamish5

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial