Set "Cancel" button action - Java

Yes.

Swing looks like it may have gotten easier to use but back in the day, I would make dedicated buttons and rely on my listeners and try catch blocks to make sure things got handles in the proper way. Lots of baby sitting in code but it always worked. That may be why I hate making UIs to this day though. It just ain’t pretty no matter what language you are using.

What, exactly, are you trying? I expect changes have been made to the initial code that you posted, if you can update us on where you’re at we might be able to help.

Also Swing has been superseded by JavaFX, so it’s not really getting updated anymore (still works fine though).