It is necessary that when a file is selected in JFileChooser
file is displayed without an extension. How? Maybe there is a better way than to inherit JFileChooser
?
I use this code here:
fc.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { File selectedFile = fc.getSelectedFile(); String path = selectedFile.getPath(); path=FilenameUtils.removeExtension(path); fc.setSelectedFile(new File(path)); } });
But in this case, the selection marker jumps up. And JFileChooser returns an incorrect file name (returns a file without an extension)