0

I have a main JFrame containing a JPanel with some stuff in it. Among other things, another JPanel with a list of sub-JPanels and JComponents in it.

What I want to do is to refresh the window (or only the list) by pressing a button in another JFrame. I tried to do it by

    Mainclass.frameIWantToRefresh.invalidate();
    Mainclass.frameIWantToRefresh.validate();
    Mainclass.frameIWantToRefresh.repaint();

But it doesn't work and I have no idea how to do it in another way.

Any clues?

Froxx
  • 957
  • 4
  • 14
  • 27
  • 3
    Please read [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice) – DavidPostill Sep 05 '14 at 14:05
  • What is supposed to happen when you refresh it? – ControlAltDel Sep 05 '14 at 14:11
  • 1
    1. [read](http://stackoverflow.com/help/mcve) 2. fix question after read. 3. ewwww static calls 4. Read @DavidPostill comment – Paul Samsotha Sep 05 '14 at 14:13
  • Oh ok, I didn't notice the problem with multiple frames, yet. I'm pretty new in Swing programming. Thanks for that! I'll work on the code to fix it and come back later. @peeskillet: What's the problem with static calls? – Froxx Sep 05 '14 at 14:39
  • Without seeing more code, it suggest poor design. Poor in the sense you are making all your components static so you can access them from other classes. That is not the correct way to communicate between components/classes – Paul Samsotha Sep 05 '14 at 14:41

0 Answers0