Below are my code
public static void main(String args[]){
JOptionPane pane = new JOptionPane();
pane.showInputDialog(null, "Question");
Object value = value.getValue();
System.out.println(value.toString()); --> this will print out uninitializedValue
}
I basically want to detect when the user click the cancel in JOptionPane and when the user close the JOptionPane
You should do this:
String s = JOptionPane.showInputDialog(null, "Question");
System.out.println(s);
This will return a null
string if the pane is closed or Cancel is pressed.