JFormattedTextField for paths?

H

Hendrik Maryns

Hi,

I have a GUI which shows a button to select a file on the file system,
with a textfield next to it that then shows the path selected. I want
to ensure, however, that no garbage is input in the text field. The
easy way is of course to make the text field uneditable, such that the
user is forced to use the button and the JFileChooser popping up.
However, it would be nice (I’m a bit Linux-oriented), if one could type
in a file path as well, and this would be validated. Is there a custom
JFormattedTextField available for this? Preferably, it should work on
all platforms, of course.

Cheers, H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFH8loAe+7xMGD3itQRAoQlAJ40D1SNEHFA6wWCGtFKl2SEl16AJwCfS7gS
moLmKH8HJbOi3Njgg0wMyxY=
=LYC7
-----END PGP SIGNATURE-----
 
M

Mark Space

Hendrik said:
Hi,

I have a GUI which shows a button to select a file on the file system,
with a textfield next to it that then shows the path selected. I want
to ensure, however, that no garbage is input in the text field. The

Good question. I did a quick web search. java.io.File will provide
some kind of validation (presumably, specific to the platform on which
you are running) and getCanonicalFile() will make a full localized path
to a file (I think that's what they mean by "canonical").

So I guess no text field, but you should be able to validate it yourself
fairly easily, if the above works.
 
C

CHAFIK Wassime

Mark said:
Good question. I did a quick web search. java.io.File will provide
some kind of validation (presumably, specific to the platform on which
you are running) and getCanonicalFile() will make a full localized path
to a file (I think that's what they mean by "canonical").

So I guess no text field, but you should be able to validate it yourself
fairly easily, if the above works.
hello
and also validating input compelling the user to put a valid path before
pushing the button :) go here
http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#inputVerification
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,216
Latest member
topweb3twitterchannels

Latest Threads

Top