ファイルがすでに存在する場合にユーザーにプロンプトを表示する[名前を付けて保存]ダイアログをJavaに実装しましたが、デフォルトで[いいえ]オプションを選択したいと思います。どうすればよいですか?
これが私の現在のコードです:
JFileChooser chooser = new JFileChooser()
{
public void approveSelection()
{
File selectedFile = getSelectedFile();
if (selectedFile != null && selectedFile.exists( ) )
{
int response = JOptionPane.showConfirmDialog(
this,
"The file " + selectedFile.getName() + " already exists."
+ " Do you want to replace the existing file?",
getDialogTitle(),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
if (response != JOptionPane.YES_OPTION )
{
return;
}
}
super.approveSelection();
}
};