Scusa un'attimo!
Hai aggiunto il windowListener?
E il codice per far apparire il l'optionPane?