Click out event
I'm creating a GUI with Swing + Substance, and I want to add a JTextField that, when clicking on it, is enabled and set for edition, and, when clicking anywhere else, is disabled again. It's something like text fields for Gmail contacts. My problem is I can't find the way to get that "clicking out" event. May anyone lend me a hand? Thanks a lot!
Try a focus listener. Google is your friend.
Thanks! I'll try that... I'd been already searching on Google, but found nothing, so... :_(
Originally Posted by KevinWorkman
I've solved my problem, so I'll post how!
The JTextField just needs to handle focusLost event, and do there want we want. In addition, I included an event handler for mouseClicked on the window containing the text field (no matter it is inside of a panel that is inside of another panel, etc. xD). Inside of my mouseClicked handler, I requested to obtain the focus with requestFocus(). Now focusLost handler is called even when you click in some part of the window not containing any component ;)
Thanks to KevinWorkman for the clue on focus listener!