Instead of separate frames look at using the CardLayout class.