I have a Swing application which connects to database with using of JPA(EclipseLink). There is a special form in the application, which contains JTree and some JTextFields. JTree is filled by enitities from database. When user clicks on a leaf of JTree, chosen entity is binding its fields to JTextFields. The problem is I don't know how i can determine if user made any changes in textfields or not. When user is choosing another leaf in the JTree I would like to ask him whether he wants to save changes or not, but he should be asked only if changes were really made. Please give me an advise how could I implement such a scheme? I was thinking to do it with help of JPA, but JPA EntityManager doesn't have any methods which could show me that Entity is "dirty". Thanks in advance.
depending on how you've structured your code, you may need to remove the listener
prior to selecting a new leaf (which populates the textfields with respective data),
then adding it back, after leaf selection.
Joined: Jul 26, 2012
Michael Dunn wrote:if there's only a few textfields, perhaps a DocumentlListener might suit.
Michael, thank you my friend, that DocumentlListener really helped me.