user613853
user613853

Reputation: 51

JFilechooser's file name textfield

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

Answers (1)

jzd
jzd

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

Related Questions