I'm working on a Java (Swing) program implementing Huffman algorithm. It takes a file and compresses it to filename.huff I have to make the JFileChooser show every file in the system but not the ones I have compressed that have .huff extension
I haven't tried any code because I don't know how can I do that. But I know how to make a FileFilter that shows only specific type of Files:
FileFilter filter = new FileNameExtensionFilter("Huffman File","huff");
JFileChooser j = new JFileChooser(System.getProperty("user.dir"));
j.setFileFilter(filter);
int returnVal = j.showOpenDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION) {
txtBrowse.setText(j.getSelectedFile().getAbsolutePath());
}
So, the question is how to make FileFilter displays all type of files except .huff files?
Use a
javax.swing.filechooser.FileFilterwhich:Note the bold part which was obtained after a few moments glancing at the methods of
JFileChooserThis is something you should do before asking questions on SO.Here is the effect of implementing one using
.txtas the file to exclude: