reading JOptionPane when cancel is hit
Sorry for asking a question i could probably find in the api, but i gotta get some sleep before class tomorrow!!
Im trying find out how i could find out if the cancel button is hit in JOptionPane. does it give a null? like if i was to do the following String someText =JOptionPane.showInputDialog(null, "enter some stuff"); and the cancel button was hit how would i know? thanks |
Yeah, it will return null if you click cancel. If you click OK without typing anything, then you will get an empty String, which is not null. Test this:
Code:
import javax.swing.*; |
Quote:
String someText = JOptionPane.showInputDialog(null, "hit cancel"); !=null or better put String st1, st2; st1 = new String("null"); //which is how JOptionPane will store it st2 = new String(null); st1 != st2 which is what im trying to get arround. |
All times are GMT -5. The time now is 01:49 AM. |