Closed ciis0 closed 1 year ago
SO suggests this is due to using addChoosableFileFilter
and not setFileFilter
.
I'll check whether that does what I want.
According to the same link, reading further down, the default is true. The dialog creation for the intended extension doesn't set the setAcceptAllFileFilterUsed to false. To expand on this, the preset methods which add specific extension for the file chooser currently doesn't set a default extension. I can look into setting the default extensions, most likely alphabetical order if there are more than one extension for the given preset.
I would prefer to keep the All Files, it should just not be the default. :)
@Colbix Are there any disadvantages in replacing addChoosableFileFilter()
with setFileFilter()
? It seems to work, at least with the Swing FileChooser.
@kaikramer The Swing FileChooser will work, no disadvantages at all. The JavaFXFileChooser that will need to be updated to accept the method for setSelectedExtensionFilter. At the moment it's just adding the extensions instead of setting the default filter.
Created PR #386 to update the JavaFXFileChooser class. Should allow for setSelectedExtensionFilter. Tested with multifile selection, single file selections, and with/without All Files. If you can think of anything else to test please let me know. I also took the opportunity to move some of the logic loops into their own function to reduce repeated actions.
After this update the FileChooserFactory class can be updated to reflect which ever default file extension is needed.
Works wonderfully, thank you! :)
Thank you for creating and maintaining KSE!
I have been using it regularly lately and found this small annoyance.
Describe the bug
When opening file, e.g. for Certificate Extension Templates, the Open (and Save) chooser default to "All Files", although appropriate
*.cet
filters are present.To Reproduce Steps to reproduce the behavior:
Expected behavior
I would expect the
*.cet
filter to be pre-selected.Screenshots
Environment
5.5.1
17.0.1
(the embedded one)