Dragging Rectangle code

Challenging problem

Here is a program that drags a rectangle and then draws it. It is very useful if you need to implement dragging code. So far it only works when you drag down and to the right.
It is extremely annoying to try and get it working so that you can drag in other directions -- it took me hours to get it working.
This is a logic problem, not a problem based on complicated graphics.

  1. Get the source code here (which is only for 1 direction of drag)
  2. Example .class file is here (right click and download to save, then run it). Nope. Still have to get the class file uploaded
  3. Add in comments explaining what the variables do (and when they are used: eg. why is mx=-1 ?) and what the if statements are checking for
  4. Get the code working so that you can drag in other directions too. Add comments as you do this.