Refreshing a JTable in a client/server application

橙三吉。 提交于 2019-12-12 05:42:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!