Adding JPanels from other classes to the cardLayout
问题 I've got 3 windows in 3 separate classes and I would like to use cardLayout so that when you click the next button, the next window will appear. How do I add JPanels containing different elements to one cardLayout? This is the first window: (the only difference is the background though - but it represents the idea of how I got it actually) public class Window1 extends JPanel implements ActionListener { static CardLayout cardLayout = new CardLayout(); public Window1() { init(); } private void