I am creating a setup appplication. I have a main class which initialize an application; which has a JFrame and 2 JPanel variable namely panelX and panelY. This main class creates a JFrame and add panelX and panelY to it. In these panels panelY has three JButtons (namely Back, Next and Quit). panelY remains as it is during entire process. Where panelX changes its contents as on the click event of Next and Back Button.
I also have some other classes. These classes has a method which returns JPanel having different conponent added to them.
In my code when I click Next Button as well as Back Button following steps occure
1) I calls removeAll() method to remove all the componant of panelX
2) panelX is assinged to null.
3) Call is made to respective method of the above classes and which returns JPanel. This returned JPanel is assigned to panelX.
Ex.
panelX.removeAll();
panelX=null;
panelX=getNextPanel();
4) After above step; I call repaint(); and validate method on panelX.
Ex.
panelX.repaint();
panelX.validate();
The problem is when I press Next Button Its shows proper panel but when I press Back Button after 2 time clicks on Next button and moves mouse pointer on panelX it shows componants of previous assigned panel as well.
So please tell me friends how I solve this problem.
Thank You!
