Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple text components kept in sync

Status
Not open for further replies.

kmcculler

Programmer
Jul 5, 2000
81
US
Hi,
I'm lookin at a rather multilayered problem concerning Javax swing text components. In a nutshell I have several JTextFields spread across multiple panels(like in tabs or an inactive window the user could click back onto) that represent the same data, so they have to be kept in sync with each other.
First as a background I've extended the JTextField so that I can give it a "data" object (an object that represents info from a database record) and setup automatic listeners in the extended textfield that update the data object whenever its text is changed.
I did find that if I passed the text fields all the same document (the class not .txt file) that they would keep in sync visually but behind the sences it 5 textfields tried to update one data object at the same time and threw several errors.
Anyone have some suggestions for me? Kris McCuller
Programmer Portiva Corp.
kmcculler@portiva.com
 
Im not sure what is causing this but you may want to try using the "synchronized" keyword. Swing is a threaded model and as such all of the text fields could be trying to access the one data object at the same time causing the VM to fall over in a heap.

Since using "synchronized" causes such performance hits try only synchronizing the method that the text fields access instead of all of hte data object.

Let me know what the result is, and if you manage to work it out, I am most curious.
----------------------------------------
There are no onions, only magic
----------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top