| # GUI Commands User Guide ## Version 2.1 |
| # Close Window Command The `CloseWindowCommand` provides common functionality for closing dialogs and frames. Its main features are: Automatically installs a `WindowListener` to handle window manager initiated close operations. Automatically closes the window when the command accelerator is activated. Supports generics so you can easily implement custom close behaviours. The following is a quick example that closes the dialog whenever Escape is pressed:
       # define the configuration.
       close-dialog@face.text=_Close@ESCAPE

       // Create the command
       JDialog dialog = ...;
       closeCommand = new CloseWindowCommand("close-dialog", dialog);
If you need the frame to be disposed on close you can call `setDisposeOnClose(true)`. If you need greater control can use generics and override the `handleClose(...)` method.
       MyFrame frame = ...;
       closeCommand = new CloseWindowCommand<MyFrame>("close-frame", frame)
       {
          @Override
          public void handleClose(MyFrame frame)
          {
             // perform specific close operations here..
             frame.doSomethingSpecial();

             frame.setVisible(false);
             frame.dispose();
          }
       }