Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to know when the user changed the contents of a JFormattedTextField?

809259Jan 31 2012 — edited Mar 24 2012
Hello for everybody!

Have you ever needed to track, in a class that extended the JFormattedTextField class or whatever, when the user really make changes to the text of the component? I mean, I'm talking about USER CHANGES, not the changes that the JFormattedTextField makes internally to its text or value in conjunction with its various formatters. I'm struggling with this issue in a component that I inherited from the JFormattedTextField and I must confess that it is really frustating. It seems that there's no specific way to know if it was the user that made the change or the component. Maybe it seems that the only way is to use brute force and to override the processKeyEvent method and track the specific keys. But then, to make the solution complete, I will have to track when something is pasted as well.

I would like to know your thoughts on this. Have you ever faced this issue? Is there a way to overcome it?

Thank you.

Marcos

PS.: I don't need to know what was changed in the JFormattedTextField. It suffices just to know that the user changed (typed or pasted) it.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2012
Added on Jan 31 2012
15 comments
649 views