Link to home
Start Free TrialLog in
Avatar of gdkinney_2
gdkinney_2

asked on

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?

Thanks
Avatar of gdkinney_2
gdkinney_2

ASKER

This is a Java application using Netbeans so the forms are TopComponents which I believe extend JPanel.
Avatar of CEHJ
>> 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
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
How would I use the Property Change Listener to do this?  Is that the way to go?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial