package test;
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileSystemView;
public class Demo {
public static void main( String[] args ) throws Exception{
JFileChooser chooser = new JFileChooser( new View() );
chooser.showOpenDialog( null );
}
}
class View extends FileSystemView{
@Override
public File[] getRoots() {
File file = new File( "c://program files" );
System.out.println( file.exists() );
return new File[]{ file };
}
@Override
public File getDefaultDirectory() {
System.out.println( "default" );
return getRoots()[0];
}
@Override
public File getHomeDirectory() {
System.out.println( "home" );
return getRoots()[0];
}
@Override
public File createNewFolder( File containingDir ) throws IOException {
// TODO Auto-generated method stub
return null;
}
}