Author: tchemit Date: 2008-04-03 21:53:22 +0000 (Thu, 03 Apr 2008) New Revision: 322 Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/UIHelper.java Log: UIHelper (should put inside a method to compute table size) Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/UIHelper.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/UIHelper.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/ui/UIHelper.java 2008-04-03 21:53:22 UTC (rev 322) @@ -0,0 +1,45 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs.ui; + +import javax.swing.JDialog; +import javax.swing.JRootPane; +import javax.swing.Action; +import javax.swing.AbstractAction; +import javax.swing.JComponent; +import javax.swing.KeyStroke; +import java.awt.event.ActionEvent; + +/** + * UI Helper methods + * + * @author chemit + */ +public class UIHelper { + public static void setQuitAction(final JDialog ui) { + JRootPane rootPane = ui.getRootPane(); + //rootPane.setDefaultButton(accept); + + Action quitAction = new AbstractAction("quit") { + private static final long serialVersionUID = -869095664995763057L; + + public void actionPerformed(ActionEvent e) { + ui.dispose(); + } + }; + rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit"); + rootPane.getActionMap().put("quit", quitAction); + } +}