• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

I want to make a change in a Java form and save it and make the change appear on another Java screen

I have a Java application where I am using Netbeans and I am changing a String field called name on the form and saving it to the database.  I want to make the change appear and update in another open screen without having to close and reopen the other screen.  How can I do this?

1 Solution
gdkinney_2Author Commented:
This is a Java application using Netbeans so the forms are TopComponents which I believe extend JPanel.
>> How can I do this?

a. add the second window as a listener to the form field of the first
b. try reading it from the db and update the second form
If both screens are controlled by one application, you can
add ActionListener to the textfield where the user inputs the string.
Then when the user pressees enter in this TextField
it will go to actionPerformed method where you can update another screen.
You can also save to database at that momemnt if necessary.

ActionListener will require pressing Enter
You can aslo use keyListener - it will report event when each key is pressed
but with that it is difficult to kniow when the user
finished input
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

You can use a DocumentListener to listen for changes to the textfield, and have the listener update the other form.

Or if its two text fields (one on each form) then you can simply have the two share the same Document model and they will both then stay in sync automatically
gdkinney_2Author Commented:
How would I use the Property Change Listener to do this?  Is that the way to go?
No a DocumentListener for text fields

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now