The problem likely is that the panel you are hiding is still behind the "invisible" one.
Try
panel1.hide();
panel1.visible = false;
panel2.show();
panel2.visible = true;
panel2.BringToFront();
I am sure that the .hide or .visible methods are probably not both necessary but you'd have to test it.