View Javadoc

1   /*
2    * Copyright (c) 2007 Creative Sphere Limited.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *
10   *   Creative Sphere - initial API and implementation
11   *
12   */
13  package org.abstracthorizon.aequo.action;
14  
15  import java.awt.event.ActionEvent;
16  import java.awt.event.KeyEvent;
17  
18  import javax.swing.Action;
19  import javax.swing.JFrame;
20  import javax.swing.KeyStroke;
21  
22  /**
23   * Closes the window
24   *
25   * @author Daniel Sendula
26   */
27  public class CloseWindowAction extends BaseAction {
28  
29      /** Window */
30      protected JFrame window;
31      
32      public CloseWindowAction() {
33          setName("Close");
34          setMessage("Close window");
35          setDescription("Close window");
36          putValue(Action.MNEMONIC_KEY, KeyEvent.VK_ESCAPE);
37          putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
38      }
39      
40      /**
41       * Sets the link window to close
42       * @param window
43       */
44      public void setWindow(JFrame window) {
45          this.window = window;
46      }
47  
48      /**
49       * Closes the window
50       * 
51       * @param e event 
52       */
53      public void perform(ActionEvent e) {
54          window.dispose();
55      }
56      
57      
58  }