Normal java app

I know this is way off topic but I don't know where else to ask. It feels like I've been though every google search possible. I have also been in a whole list of irc channels… anyways I don't want my frame to close if I click the x at the top of the screen I want it to ask do you want to save yes no or cancel (cancel should make it stop quiting) I don't have a problem with writing the prompt but it still quits after some one would press cancel thats what I'm struggling with.

here's my app:

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;

 * @author Willem Dreyer
public class Capp implements ActionListener {

   static JFrame frame;

   private static void createAndShowGUI() {

      JPanel mainPanel = new javax.swing.JPanel();
      JMenuBar mainMenu = new javax.swing.JMenuBar();
      JMenu fileMenu = new javax.swing.JMenu();
      JMenuItem exitMenuItem = new javax.swing.JMenuItem();


      frame = new JFrame("Capp");

      JLabel jlabel1 = new JLabel(":P");
      exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {

      mainPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 12, 12));
      mainPanel.setMinimumSize(new java.awt.Dimension(297, 200));

      frame.addWindowListener(new java.awt.event.WindowAdapter() {
         public void windowClosing(java.awt.event.WindowEvent evt) {

      frame.setSize(new java.awt.Dimension(400, 200));
      Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      Dimension frameSize = frame.getSize();
      frame.setLocation(new Point((screenSize.width - frameSize.width) / 2,
            (screenSize.height - frameSize.width) / 2));

   protected static void exitForm(WindowEvent evt) {
      System.out.println("shuting down");
      //Here I don't want it to exit!?

   protected static void exitjMenuItemActionPerformed(ActionEvent evt) {
      System.out.println("shuting down");
      //new Exit(frame).setVisible(true);

   public static void main(String[] args) {
      javax.swing.SwingUtilities.invokeLater(new Runnable() {
         public void run() {

   public void actionPerformed(ActionEvent arg0) {

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); is maybe the problem?

Yay got it thx for the tip shingoki