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

http://docs.oracle.com/javase/7/docs/api/java/awt/Container.html#add(java.awt.Component)

JFrame inherits/overloads add() a few times so it depends on what the GamePanel object is.

http://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html#setContentPane(java.awt.Container)

GamePanel extends JPanel. If that helps.