问题
I developed a Java client/server application, communicating via Spring RMI, the Client is symply a swing Jframe how containing at the top a command buttons(add, update, delete), in the middle a JTable, and at the bottom, a form.
the server side contains simply a Dao layer by using iBatis witch communicates with an Apache Derby database.
So the application works greatly, but two problems are found :
1) when the user A adds/updates/deletes a row from a JTable, the others can't see the changes until clicking a button to refresh the data in the JTable, I wanna that this changes must be done automatically.
2) when the user A wants to update a row in the JTable, and the user B wants to changes the same row, when done, always teh programme keeps the last data saved.
can some one give a working code ? or a link to a website, tutorial ....
回答1:
1) when the user A adds/updates/deletes a row from a JTable, the others can't see the changes until clicking a button to refresh the data in the JTable, I wanna that this changes must be done automatically.
Add a TableModelListener to the TableModel. You will recieve an event whenever data is changed so you can update the server right away.
来源:https://stackoverflow.com/questions/5083156/refreshing-a-jtable-in-a-client-server-application