Both JPanel and JFrame extend the Container class. Did you try using a reference to the JFrame where the code you found used the JPanel?