• Post Reply Bookmark Topic Watch Topic
  • New Topic

JFileChooser - Do not allow any input in the textfield

 
Pomchi Bedi
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Need help with JFileChooser.

When the filechooser is displayed, the user can either select a file or they can type in a file name and select Open to open the file. I do not want the user to be able to type in any filename in the textfield. Is there a way to disable the filename textfield, so that they can only select a valid existing file.

Any help will be much appreciated.

Thanks

Pomchi
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this might be one way

 
Pomchi Bedi
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael.

I was thinking that there would be some standard way to achieve this. Instead of catching the FileNotFoundException, it is better not to allow user to type in any junk in the filename field.

Thanks again for the quick response.

-Pomchi
 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!