I had a bad right knee since I was born with my knee out of alignment. I swam anyway but with pain. Luckily, I found a great ortho (Atlanta Falcon's ortho) and he fixed the knee. Right before the surgery, my quad atrophied from the knee being so bad so I've been through the worst.And in the mean time, I had exercises that I had to do when the pain got bad.
Lie flat on your back and just lift your leg straight in to the air. Go about 12 inches off the ground. Do this multiple times a day and work up to about 20 reps at a time.. This will strengthen your quad and let it reattach to your knee cap.
Also, turn your toes out to one side, put a rolled up town under your knee and raise just from your knee to your foot off the ground. This strengthens the inner muscle, which is hard to do with any machine or other exercise. Again, do this several times a day and work up to about 20 reps at a time.
Once your quad is stronger, then you can start doing more "true" exercising. But as long as the quad is weak, the knee will continue to hurt.