Obtain the Java ProgressMonitor undo event

I have a ProgressMonitor pm and a SwingWorker sw. I want to cancel the SwingWorker when I press the cancel-button on pm. I guess this shouldnt be too hard, and I read some tutorials about SwingWorker and ProgressMonitor, but I can't get this to work.