fileChooser.addChoosableFileFilter(filter)
will add a custom file filter to the list of user-choosable filters. By default, the list of user-choosable filters includes the Accept All filter, which enables the user to see all non-hidden files.
You will need to invoke: fileFilter.setAcceptAllFileFilterUsed(false)
The setAcceptAllFileFilterUsed(boolean)
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.