In my program I go from the log in to the main menu,to different areas of the site.
jPanel2.removeAll();
Items panel = new Items();
jPanel2.add(panel);
jPanel2.repaint();
jPanel2.revalidate();
I thought that I found a way to change jpanels so that I can go from one jpanel to another which in the same screen.
The problem with the above code is that each time I change jpanels, the old jpanel isn't gotten rid of, it is staying there, meaning whenever I change jpanels the jpanel slowly gets lower on the page due to it being put underneath the other jpanels that were created before it.
Is there a way to get rid of the jpanels so that when I go to a new jpanel it doesn't slowly lower down the page?