Java GUI: about getContentPane( ) method and content

Every JPanel is a container, so either add it to a panel then add it to the container or directly use add(component) or use the getContentPane().add method. Both add the component to the container in Java 7 (I don’t know if version 6 has a problem with this or not).

Leave a Comment