I need some help. I have a JTextField named 'date' and I want to kick off some code when the user changes it's value. I first tried adding an ActionListener. It compiled, but would simply not execute (which is, I believe, because the JTextField does not actually have an action associated with it like a JComboBox or JButton does...although I don't understand why the method is available, if that's the case).
Then I added a DocumentListener and tried the insertUpdate and removeUpdate methods. This really didn't work either, because they would fire as soon as a single character changed. Therefore, if the user tried to change "27-May-2004" to "27-Apr-2004", it would fire three times...as each character in the month name changed.
I finally tried a FocusListener but, again, screwy results. It would fire if the user just tabbed across the field, even when no changes were made.
All I can think of is to save the field's value when focus is gained, then compare that String to the field's value when focus is lost to see if they are different. It seems clumsy and inefficient, especially since there are many fields (not just the one date I used as an example) which need similar processing. Isn't there a clean, easy way to detect when the full character string in a JTextField has changed?
Thanks in advance for any help anyone can provide. This has been a frustrating few days messing with this.