I'm in the process of creating a JTextField that will only contain integers. I want to prevent only having a - sign and a null string. Is there a way in Java to be notified when the JTextField loses focus, so I can perform the last checks on the input data?
Zoe, Yes, what you would do is to add a FocusListener to the JTextField and use its focusLost( FocusEvent e ) method to handle this... Personally, I would either have it blank the field, or return focus to the field and pop up a warning message... HTH, -Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
posted 15 years ago
Thanks, Your suggestions are along the same lines that I was going to to do. I just want to force them to input a number, blanks for these fields don't make sense in my application.