• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTree binding to JTextField, ask user to save data

 
Greenhorn
Posts: 7
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.
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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if there's only a few textfields, perhaps a DocumentListener might suit.

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.
 
Viktor Grafskiy
Greenhorn
Posts: 7
Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic