[英]Refresh a JTable using a JButton in another JFrame?
I've created two JFrame
s. 我创建了两个
JFrame
。 Frame 1 has a JTable
and frame 2 has a JButton
. 框架1具有
JTable
,框架2具有JButton
。 The JTable
contains data from a MySQL table. JTable
包含来自MySQL表的数据。 What I want to do is this: when I click the JButton
in frame 2, the JTable
in frame 1 needs to be refreshed. 我想做的是:单击框架2中的
JButton
时,需要刷新框架1中的JTable
。 How can I do that? 我怎样才能做到这一点?
Let your TableModel
export an Action
that fires the TableModelEvent
appropriate to any changes made. 让您的
TableModel
导出一个Action
,该Action
触发适用于所做任何更改的TableModelEvent
。 Use the Action
to construct the button. 使用
Action
构造按钮。 When the button is clicked and the Action
fires, any table listening to the table model will update automatically. 单击该按钮并触发
Action
时,任何侦听该表模型的表都将自动更新。 There are related examples here and here . 这里和这里都有相关的示例。
See also The Use of Multiple JFrames, Good/Bad Practice? 另请参阅使用多个JFrame,良好/不良做法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.