Difference between adding to a JFrame and setting ContentPane ?

I want to know what is the difference between these 2 lines and which should i use ?


JFrame window = new JFrame("Game");
window.add(new GamePanel()); --------------------------------> This line
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
window.pack();
window.setLocationRelativeTo(null);
window.setVisible(true);


JFrame window = new JFrame("Game");
window.setContentPane(new GamePanel()); --------------------> This line
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setResizable(false);
window.pack();
window.setVisible(true);

Thank You