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 / JFace and the fly likes JFormattedTextField validation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "JFormattedTextField validation" Watch "JFormattedTextField validation" New topic
Author

JFormattedTextField validation

Nicol Green
Ranch Hand

Joined: Jan 30, 2010
Posts: 66
When I was thinking which to choose JTextField or JFormattedTextField I thought that it would be much easier to program JFormattedTextField, it's name says that, too but now I am dealing with some problems. I consider that should be possible quickly to be done, but not here..

I have a



I would like to say:

1. inputLenght, not longer then for example 20.
2. Still I cannot use FormattedFactory, because of that initial value. setEditable, or setEnabled is not working in this case.

I feel that it is some trivial solution, or, I hope! So, any tips are welcome! Thank you!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 25060
Don't know. I presume you have looked for tutorials like this one?

I think this thread would sit better on our GUIs forum, so I shall move it.
Michael Dunn
Rancher

Joined: Jun 09, 2003
Posts: 3619
a JTextField with DocumentFilter set might suit you better
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Or perhaps all you need to do is use a standard JTextField and simply parse the textfield's text within a try/catch block, catching for NumberFormatException.

This message was edited 1 time. Last update was at by pete stein

Nicol Green
Ranch Hand

Joined: Jan 30, 2010
Posts: 66
Yes definitely, JFormattedTextField was not the best option in my case. I will try what you proposed, and than tell you what was the best solution.

Thanks!
 
 
subject: JFormattedTextField validation
 
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture