Is there a difference between them and are there any conditions in which one should be used instead of the other?
Both calls are the same. In Java 5, they changed jframe.add to forward calls to the content pane.
jframe.add
From the Java 5 release notes:
Lastly, after seven years, we've made jFrame.add equivalent to jFrame.getContentPane().add().
Also, see the javadocs.
2.1m questions
2.1m answers
60 comments
57.0k users