I am using the FileNameExtensionFilter to filter the file type but when the user selects the open button, they have the option to select "All files" from the file type. is there a way to disable that option?
FileFilter filter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg");
JFileChooser fileChooser = ...;
fileChooser.addChoosableFileFilter(filter);
so something to add to above code which disallow user to select any other file?
Take a look at JFileChooser#setAcceptAllFileFilterUsed
Determines whether the AcceptAll FileFilter is used as an available choice in the choosable filter list. If false, the AcceptAll file filter is removed from the list of available file filters. If true, the AcceptAll file filter will become the the actively used file filter.