捕捉JDialog的关闭事件

JDialog的关闭事件是什么?
问了几个群,网上也找了好久都没有正确答案,还是靠自己吧。下面是我的测试代码:
	public class EditJDialog extends javax.swing.JDialog implements WindowListener{
		

		public EditJDialog(Frame owner, boolean modal) {
			super(owner, modal);

			setSize(800, 600);
			setVisible(true);
			//setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			this.addWindowListener((WindowListener) this);
		}

		@Override
		public void windowActivated(WindowEvent e) {
			System.out.println(0);
			
		}

		@Override
		public void windowClosed(WindowEvent e) {
			// TODO Auto-generated method stub
			System.out.println(1);
		}

		@Override
		public void windowClosing(WindowEvent e) {
			// TODO Auto-generated method stub
			System.out.println(2);
		}

		@Override
		public void windowDeactivated(WindowEvent e) {
			System.out.println(3);
		}

		@Override
		public void windowDeiconified(WindowEvent e) {
			// TODO Auto-generated method stub
			System.out.println(4);
		}

		@Override
		public void windowIconified(WindowEvent e) {
			// TODO Auto-generated method stub
			System.out.println(5);
		}

		@Override
		public void windowOpened(WindowEvent e) {
			// TODO Auto-generated method stub
			System.out.println(6);
		}


	}

点击关闭按钮,结果是3。可以推定对应的事件是windowDeactivated,而不是网上所说的windowClosing。
哪位给个评论,为何网上说的与我的实验会不同?

你可能感兴趣的:(html,swing,sun)