Replace File Confirmation fow swing

Its not much, but i found it a bit strange that swing didnt already do this so i made a subclass of jfilechooser that asks the user if they want to replace the file when selecting to save an existing file.



import java.awt.*;
import javax.swing.*;
import java.io.*;

/**
 *a filechooser that checks the user wants to when returning an existing filename
 */
 
public class CheckFileChooser extends JFileChooser{
	
	public void approveSelection(){
		if(getDialogType() == SAVE_DIALOG){
			File sel = getSelectedFile();
			if(sel.exists()){
				int ow = JOptionPane.showConfirmDialog(this, 
					"The file "+sel.getName()+" already exists, do you want to replace it?",
					"Replace File?",
					JOptionPane.WARNING_MESSAGE);
				//user clicked cancel?
				if(ow != 0)
					return;
			}
		}
		super.approveSelection();
	}
}