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.
1.4m articles
1.4m replys
5 comments
57.0k users