Maybe I'm being too lazy, but it seems much faster to ask questions than to read. Is it necessary for the class to extend JPanel, or is that just a design preference? I'll look up what extend means.
Yes, you must extend JPanel. Or some other Swing class, but JPanel is probably the best.
You are overriding the paintComponent method of JPanel.
I'm still a bit confused about the paintComponent method. So it comes up automatically, and I call any methods for drawing things from within it?
Look, the AWT Event Thread calls f.paint(). You tell it to start doing this when you call f.setVisible(true).
f.paint() calls the paint(g) method of Test because you put the Test object into the JFrame with f.setContentPane(new Test()).
The paint(g) method of Test calls the paintComponent(g) method of Test. That's how it gets called.
You have to either read a tutorial. You could buy a book about Swing as well, but the Java Tutorial is a good source for information about Swing. Spending a couple of days reading the tutorial is the only way you're ever going to understand. Asking random questions isn't effective.
For actual game programming, I would suggest reading Developing Games in Java and/or Killer Game Programming in Java. However, they don't really address the basics of Swing too much.