You should almost definitely be using a real layout manager and a CardLayout to do the switching between panels.