Hi, I'm reading the Head First Java book and am having problems using the example regarding the paintComponent method (pg. 364 chapter 12). I've made a subclass of JPanel but cannot seem to call the paintComponent method. I've pasted my code below; any tips would be appreciated!
Don't hijack old postings. This posting is about "painting". Your question has nothing to do with painting.
Read the section from the Swing tutorial on Using Top Level Containers which will help explain the structure of a JFrame and its child components. The Swing tutorial is probably a better reference than Head First Java because it is more current.
In the first case you are replacing the content pane with your panel.
In the second case you are adding your panel to the content pane.
Effectively they are the same because you can still add components to the frame however you want.
Look at the examples in the Swing tutorial to see which approach is used most often.