mouseMoved is a busy method and trying to get it to do too much can bog things down. I can think of three ways to reduce the workload in your app. Two of these are traditional: 1 — limited redrawing as shown by Brian, and 2 — drawing the grid on an image which you draw as a background.
Joined: Nov 01, 2006
First of all thank you very much for your responses! I haven't been using this forum that much, but it seems as if people in here are quite pleasant company Too, I've been trying to help out other users in dire need of guidance, but I seem to stumble across questions out of my area of knowledge or I'm too late with my reply, someone else has already helped the poor fellow out. Hopefully some day I can give back to the forum what it (or it's users to be more precise) has given me.
Back to Topic!
To Brian Cole: I fully understand your idea, but unfortunately by limiting the scope of the repainting, I get trailing debris from the Box the pointer is carrying around. Too, in the "real" application this object can be of various sizes and include alignment lines crossing from one side of the screen to the other. So to make your solution work in all situations, the area needed to be repainted is in worst case scenario:
To Craig Wood: This is EXCELLENT! Thank you so very much! I had no idea that images are updated that fast! I understand that drawing the grid using drawLine() is quite a lot of painting, and I was looking for an idea that made the Graphics object capable of only updating the drawLine()'s needed. Your solution does (afaik) exactly that: Only repaints the areas of the image that are smothered by debris from moving the pigs skin colored box around.
I'll implement your solution into the "real" application tomorrow, I hope it'll work as much as a charm as it did in my mock-up example.