Problem with setDefaultCloseOperation

Hello, after read a few post about this problem neither of them can help me to solve my problem. I hope that you can help me. My problem is the following:

I've installed java1_5_11 and eclipse with Visual editor.

When I tried control the " X" button of the window, launching a jOptionPane asking to the user If he want exit to the application. If I clicked on anyone of options (yes or no) the application is closed.

I run the .java with java bean.

My example is the following:

package pfc.visualinterface;

import java.awt.BorderLayout;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JFrame;

import javax.swing.WindowConstants;

public class cawen extends JFrame {

private static final long serialVersionUID = 1L;

private JPanel jContentPane = null;

/**

* This is the default constructor

*/

public cawen() {

super();

initialize();

}

/**

* This method initializes this

*

* @return void

*/

private void initialize() {

this.setSize(300, 200);

this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

this.setContentPane(getJContentPane());

this.setTitle("JFrame");

this.setVisible(true);

this.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

int opcion = JOptionPane.showConfirmDialog(cawen.this,"Do you really want to exit?", null, JOptionPane.YES_NO_OPTION);

if (opcion == JOptionPane.YES_OPTION){

System.exit(0);

}

}

});

}

/**

* This method initializes jContentPane

*

* @return javax.swing.JPanel

*/

private JPanel getJContentPane() {

if (jContentPane == null) {

jContentPane = new JPanel();

jContentPane.setLayout(new BorderLayout());

}

return jContentPane;

}

public static void main(String[] args) {

new cawen().setVisible(true);

}

}

Sorry but I don't speak english very well. Thanks in advance

[2219 byte] By [Tukamona] at [2007-11-27 9:41:26]
# 1

Don't forget to use the "Code Formatting Tags",

see http://forum.java.sun.com/help.jspa?sec=formatting,

so the posted code retains its original formatting.

Works fine for me using JDK1.4.2 on XP when executing from the command line.

Maybe its an Eclipse problem or a version problem.

camickra at 2007-7-12 23:20:26 > top of Java-index,Desktop,Core GUI APIs...
# 2
also works OK for me (clicking 'No' and the app stays open)java 1.6.0_01 winxp
Michael_Dunna at 2007-7-12 23:20:26 > top of Java-index,Desktop,Core GUI APIs...