|
A suggestion: add some debug statements (println()) that show how the values of your variables change.
Also some comments in the code describing what you are trying to do would be helpful.
For example why do you draw(rect) in paintComponent and then draw(r) in drawRect()?
|