Java Swing KeyStroke strokeToPrefs(KeyStroke prefsStroke)

Here you can find the source of strokeToPrefs(KeyStroke prefsStroke)

Description

Converts a KeyStroke into a string representation for preference storage.

License

Open Source License

Parameter

Parameter Description
prefsStroke the KeyStroke to convert

Declaration

public static final String strokeToPrefs(KeyStroke prefsStroke) 

Method Source Code

//package com.java2s;
/*/* www.  j a v  a 2  s .  c om*/
 *  PrefsUtil.java
 *  Inertia
 *
 *  Copyright (c) 2004-2005 Hanns Holger Rutz. All rights reserved.
 *
 *   This software 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, june 1991 of the License, or (at your option) any later version.
 *
 *   This software 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 (gpl.txt) along with this software; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *
 *   For further information, please contact Hanns Holger Rutz at
 *   contact@sciss.de
 *
 *
 *  Changelog:
 *      11-Aug-05   copied from de.sciss.eisenkraut.util.PrefsUtil
 */

import javax.swing.*;

public class Main {
    /**
     *  Converts a KeyStroke into a string representation for
     *   preference storage.
     *
     *  @param      prefsStroke   the KeyStroke to convert
     *   @returns   a string representation of the form "modifiers keyCode"
     *            or <code>null</code> if the prefsStroke is invalid or <code>null</code>
     */
    public static final String strokeToPrefs(KeyStroke prefsStroke) {
        if (prefsStroke == null)
            return null;
        else
            return String.valueOf(prefsStroke.getModifiers()) + ' ' + String.valueOf(prefsStroke.getKeyCode());
    }
}

Related

  1. setHotKeyForFocus(final JComponent comp, final String keyStroke, final String actionName)
  2. setKeyBinding(String actionKey, int key, int modifiers, AbstractAction action, JComponent component)
  3. setKeyStroke(JComponent component, KeyStroke keyStroke, Action action)
  4. setUpCycle(JComponent comp, int key)
  5. stringToKeyStroke(String s)
  6. synchronizeKeyboardActions( JComponent sourceComponent, JComponent targetComponent, KeyStroke[] keyStrokes, int condition)
  7. synchronizeKeyboardActions( JComponent sourceComponent, JComponent targetComponent, KeyStroke[] keyStrokes, int condition)
  8. unregisterKeyBoardAction(JComponent comp, Action action)
  9. withKeyStroke(M jmi, KeyStroke ks)