xxarmoxx
Jul 12th, 2007, 03:25 PM
How can I hide certain files in a JFileChooser control? This is what Im using so far but I can still see files I dont want to see.
JFrame frame = new JFrame();
String filename = "Desktop";
JFileChooser fc = new JFileChooser(new File(filename));
fc.setFileFilter(new FileFilter() {
public String getDescription() { return "CSV files"; }
public boolean accept(File f) {
if(f.isDirectory()) return true;
if(f.getName().endsWith(".csv")) return true;
return false;
}
});
// Show save dialog; this method does not return until the dialog is closed
fc.showSaveDialog(frame);
cFile = fc.getSelectedFile();
JFrame frame = new JFrame();
String filename = "Desktop";
JFileChooser fc = new JFileChooser(new File(filename));
fc.setFileFilter(new FileFilter() {
public String getDescription() { return "CSV files"; }
public boolean accept(File f) {
if(f.isDirectory()) return true;
if(f.getName().endsWith(".csv")) return true;
return false;
}
});
// Show save dialog; this method does not return until the dialog is closed
fc.showSaveDialog(frame);
cFile = fc.getSelectedFile();