Tuesday, April 14, 2015

paintComponent() is NOT the MVP of a game of Catch.

The paint() method is hard. Actually, that's wrong--paint() is dead, it is now paintComponent() that tortures me. My sad story began several weeks ago, when I was feeling good because I had figured out how to make a slider that could change the size of the shapes displayed by my program.
The next step was the last, I told myself. I thought I was on the verge of reaching the pinnacle... but I was wrong. I thought all I had to do was pass the Graphics() object back and forth a bit, as if I was playing a game of catch, but paintComponent() disagreed.

Much like an overweight child refusing to go outside when his father asked him if he wanted to toss a ball for a bit, paintComponent rebuked my every attempt to throw around the Graphics() object, and it stymied my progress with its devilish lack of error messages. If it had returned errors, at least I would have been able to see where and what went wrong. But no... instead, I was left in the shade, grasping for a solution before the curtains completely closed and shut out all light. If you learn nothing else from me, at least learn this: He who paints graphics should look to it himself that he does not become painted; and when you gaze long at a method the method also gazes at you.