Reputation: 51
I use JFileChooser and setSelectedFile such as "D:\outlook", and when show showSaveDialog, the file Name in JTextField is D:\ and the outlook folder selected, and I don't want like this, I want outlook folder selected and the file Name in JTextField is D:\outlook not D:\
Upvotes: 1
Views: 1696
Reputation: 23629
Instead of setSelectedFile
use setCurrentDirectory
. Like so:
public static void main(String[] args){
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("D:\\outlook"));
chooser.showSaveDialog(null);
}
Upvotes: 4