ファイルを開くためにJFileChooserを作成しましたが、ファイルを選択して開くと、ファイルを選択する時間の2番目にJFileChooserが現在のディレクトリにありません。 現在のディレクトリを開くようにJFileChooserを設定するにはどうすればよいですか?現在のディレクトリを開くようにJFileChooserを設定します
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION){
File fileName = fileChooser.getSelectedFile();
File path=fileChooser.getCurrentDirectory();
if ((fileName == null) || (fileName.getName().equals("")))
{
JOptionPane.showMessageDialog(this, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE);
}
else{
currentPath=path.getPath()+"\\"+fileName.getName();}
}