Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import javax.swing.JFileChooser; public class Main { /** * Set starting dir and file for a chooser. * chooser.setSelectedFile doesn't work correctly when given a directory. * * @param chooser * @param file */ public static void setSelectedFile(JFileChooser chooser, File file) { if (file.isDirectory()) chooser.setCurrentDirectory(file); else chooser.setSelectedFile(file); } }