I have this class
package com.javacodegeeks.snippets.desktop;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.MouseListener;
import javax.swing.JFrame;
public class Main1 {
public static void main(String args[]) {
JFrame frame = new JFrame("Window Listener");
WindowListener listener = new WindowAdapter() {
public void windowClosing(WindowEvent w) {
int response = JOptionPane.showConfirmDialog(null, " Are you sure you want isuue the ticket?", "Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.YES_OPTION) {
System.exit(0);
}
}
};
frame.addWindowListener(listener);
frame.setSize(300, 300);
frame.setVisible(true);
}
}
My problem is if the user press "No"
h/se will not see frame again.
I want the user to be able to go back to the main frame
How do I do this?
Do
frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);