I have a class here that I want to act just like a JOptionPane..
but Im stuck with returning a value.. anyway I left some of the method as void to be easily compiled, but lets assume that it returns a String value...
what I want is if I press the button it will return a value from another class that calls that method... please I need help ..
1) Give the Popup instance a value defaulting to null:
2) Set this value when you press OK
3) Returns this value from the static method: Because you initialize it to null and only set it when OK is pressed the popTheInput method will return null if the user clicked Cancel or pressed the little X.
That's because your dialog is not a modal dialog, and it does not block the event dispatcher thread. Of course in your small example, it doesn't block the main thread either, which it never will because the main thread and the event dispatcher thread are always separate from the moment you realize your user interface.