I have a Undecorated Modal JDialog which I want to setVisible(false) when the user clicks outside of the modal dialog.
Is this possible in Swing?
What I am doing is popping up a custom editor for a text field like a date selector. Is there an easier way to do what I want?
EDIT
Remember that modal blocks on the call to setVisible(true), so you can’t just say “don’t use a modal dialog”
And I’ve tried focus listeners on the dialog, they don’t trigger when its modal.
It’s not a modal dialog if you can click outside of it and “something” happens. All the answers are correct, you should be creating a non-modal dialog and then deal with your use case via a FocusListener.