在客户端/服务器应用程序中刷新JTable [英] Refreshing a JTable in a client/server application
问题描述
我开发了一个Java客户端/服务器应用程序,通过Spring RMI进行通信,该客户端是一个摆动式Jframe,它如何在顶部包含一个命令按钮(添加,更新,删除),在中间包含一个JTable,在底部包含一个,一种形式.
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.
通过使用iBatis巫婆与Apache Derby数据库进行通信,服务器端仅包含一个Dao层.
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)当用户A从JTable添加/更新/删除行时,其他用户直到单击按钮刷新JTable中的数据才能看到更改,我想此更改必须自动完成.
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)当用户A要更新JTable中的一行,而用户B要更改同一行时,完成后,程序始终保留最后保存的数据.
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)当用户A从JTable添加/更新/删除行时,其他用户直到单击按钮刷新数据后才能看到更改.在JTable中,我想必须自动完成此更改.
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.
将TableModelListener添加到TableModel.每当数据更改时,您都会收到一个事件,以便您可以立即更新服务器.
Add a TableModelListener to the TableModel. You will recieve an event whenever data is changed so you can update the server right away.
这篇关于在客户端/服务器应用程序中刷新JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!