The client has a class that implements
MouseListener and
MouseMotionListener which subscribes to mouse events that take place over the game window. Events are fired automatically by Java when the mouse is moved over or clicked on components (like the game screen, for example), so the client just takes the information it receives from there, packages it up, and sends it off to the server.
I remember hearing that Java notifies event listeners about mouse motion events roughly every 20ms or so, but the frequency at which Java learns about events probably depends on your OS and its configuration.