I have a SwingWorker that sends an HTTP request, and I override the SwingWorker done () method to change the content in the JFrame. I want to basically delete everything and add a new panel of participants in the JFrame depending on the values returned from the server.
Now the problem that I am facing is that when I call the following methods below on the JFrame, it does not remove anything from the JFrame and does not change the contents contained in the frame.
f.removeAll();
f.add(new MainDisplay(f));
f.getContentPane().invalidate();
f.getContentPane().validate();
f.getContentPane().repaint();
The current fix I have is below, but I would rather modify the contents of the JFrame and then load a new one.
f.dispose();
f=new ApplicationFrame();
I looked at the previous answers here and on Google, and some of them use validate () or invalidate (), showing redraw () to redraw the JFrame.
/ .
: , , - .