1

I have a JFrame (1, the main frame) which continues a JPanel and JTable with data. The user can edit the data. Therefore a new JFrame (2) opens and the user can input the new data. If they click "OK" in the 2nd frame, I want the 1st frame to refresh itself.

I have each frame in a different class. Frame 1 knows Frame 2, but not the other way.

I couldn't find a way to make it possible.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Stockfish
  • 61
  • 1
  • 5
  • 1) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) 2) For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). 3) Continuing from point 1 of my comment. **This definitely sounds like a good case for a *modal* `JDialog` instead of the second frame, or even more specifically, a `JOptionPane`.** – Andrew Thompson Jun 09 '18 at 19:29

1 Answers1

0

It works for me (after setting the contents of table):

frame1.invalidate();
frame1.repaint();
SwingUtilities.updateComponentTreeUI(frame1);
Sepehr1812
  • 66
  • 1
  • 5
  • This is a poor approach to this problem, especially noting that the OP says that 'frame 2' does not have a reference to 'frame 1'. See my comment above for (the beginnings of) a better strategy. – Andrew Thompson Jun 09 '18 at 19:34