This post originated from an RSS feed registered with Java Buzz
by Sam Dalton.
Original Post: Closing Swing Windows with the Escape Key
Feed Title: import java.*;
Feed URL: http://www.samjdalton.com/pebble/rss.xml
Feed Description: Random, Infrequent Bloggings of a Techie
The source of much user frustration with Swing is when windows and dialogs don't act in the way that they expect.
Generally, a user expects to be able to press the Escape key to close a dialog window (in Windows).
By default Swing JDialogs don't provide this behavior. However, this can easily be implemented by creating a simple
subclass of the JDialog class. The code below will equip any subclass with this "close on escape" functionality.