A strong magnetic field is generated by passing a current
through a set of windings. This field acts as a convex
lens, bringing off axis rays back to focus. Click on
'Draw rays' to compare the action of an electromagnetic
lens
with an optical lens.
The image is rotated, to a degree that depends on the strength
of the lens. Focal length can be altered by changing the
strength of the current.
More detail
on how magnetic fields affect electrons.
How can we change the focal length of a glass lens in a
light microscope?