Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable file input field in JFileChooser?

Tags:

java

swing

I want user to select files from existing files only and don't want to let him type the file name.
So how can we disable the file input field in JFileChooser?
Thank you.

like image 869
Supereme Avatar asked Nov 30 '22 09:11

Supereme


1 Answers

I think what you really want is for the user to select an existing file.

You would write an action listener for the JFileChooser to check and make sure the file exists.

You still want the user to be able to type in the file input field so he can limit what's displayed in the JFileChooser,

For example, if the user types *.txt, only .txt files are displayed. If the user types one*, only files that start with the letters o-n-e are displayed.

like image 191
Gilbert Le Blanc Avatar answered Dec 05 '22 10:12

Gilbert Le Blanc