Note: If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.
Parameters: comp - the component to be added index - the position at which to insert the component, or -1 to append the component to the end Returns: the component comp See Also: addImpl(java.awt.Component, java.lang.Object, int), remove(int), validate(), JComponent.revalidate()
If you look you will find several versions of the add() method, which all function as "convenience" methods, and actually call other methods. You can use add() or getContentPane().add(): both will work. But add() on its own might only work in J5 or later.