0

I've created two JFrames. Frame 1 has a JTable and frame 2 has a JButton. The JTable contains data from a MySQL table. What I want to do is this: when I click the JButton in frame 2, the JTable in frame 1 needs to be refreshed. How can I do that?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Nayana Rajapaksha
  • 161
  • 2
  • 2
  • 12

1 Answers1

1

Let your TableModel export an Action that fires the TableModelEvent appropriate to any changes made. Use the Action to construct the button. When the button is clicked and the Action fires, any table listening to the table model will update automatically. There are related examples here and here.

See also The Use of Multiple JFrames, Good/Bad Practice?

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045