The knee has two joints - the one between the femur and tibia with the meniscus, etc., and the one under the knee cap, the patellar-femoral joint.
In my opinion, pain under the knee cap is often caused by posture issues, quad strength & tightness, as discussed in the above replies.
When I had an MRI for a torn meniscus, the MRI report included serious damage to the patellar-femoral joint. (Get the written MRI report from the imaging specialist, read it and research all issues even those not being treated or showing symptoms.)
One particular issue, that of a short/tight rectus femorus, is described in this link
BE AWARE THAT STRETCHING THE RECTUS FEMORUS MIGHT PUT STRESS ON THE LOWER BACK.
The rectus femorus is special because it is the only quad that attaches above the hip joint, the other three quads attach to the femor.
I believe that this is a good description, believe that I have a short rectus femorus, and that the stretch is very effective in correcting it. It may be my over-simplified picture, but I believe that a tight rectus femorus simply causes the patella to ride too high in the joint. This damages the cartilage separating the patella from the femur. Some of the other better known patella tracking problems involve lateral tracking issues, the patella being pulled to the side or 'tilted' relative to the joint track.
Search: rectus femorus quadriceps anterior pelvic tilt