Water Hammer is technically a problem of momentum. As water moves through a pipe and whatever valve that's on the other end of the pipe shuts off quickly (electric valves are notorious for this), the water that is moving is still carrying momentum, hence the "hammer" effect.
The solutions to water hammer are: 1. Install a water hammer arrestor. They look like a toilet bowl float and their job is to absorb the impact, or momentum of the water by actually expanding ever so slightly in order to take the edge off of the hammer. It doesn't have to be installed on the toilet itself, simply on the water line supplying the bathroom.
2. Install a slower closing toilet fill system. Some close pretty rapidly, and while I don't know how to tell the difference between those that run full steam and then shut off too quickly vs ones that more gradually shut off the water, it's not an expensive fix to keep going through those on the shelves at Menards (or whatever is your favorite home improvement store).
Remember, you aren't likely seeing the water hammer effect from turning off your bathroom's faucets even though they are most likely on the same water supply line, so I would go with a different tank filler. If you tried really hard to get the hammer effect using your sink or tub faucets and are able to make it hammer, then I'd install a water hammer arrestor on the supply line going to the bathroom. Even if there's already one in place. Note, they don't "wear out" because all they do is expand and contract. If one does actually wear out, it will leak as it's expanded one time too many and has split open.
This is Fluid Mechanics 101.
I was ready to buy new guts for the toilet and an arrestor, but I wanted to check the shut off valve first. Apparently someone (motioning towards the saintly, mrs. dirtymike), had an overflow scare. The valve was barely cracked and as soon as I opened it up all the way, the problems were fixed.
As far as the fluid dynamics, I left physics 1 and 2 a wounded man. Thankfully, the aforementioned mrs. dirtymike was in class with me.