That's the first thing that comes to my mind.
//Custom button text
Object[] options = {"Yes",
"No"};
JOptionPane.showOptionDialog(this, "The file " + selectedFile.getName() +
" already exists. Do you want to replace the existing file?",
getDialogTitle(),
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE,
null, options, options[1]);
But probably there's a better approach.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…