Here you can find the source of getPrettyStringFor(KeyStroke keyStroke)
Parameter | Description |
---|---|
keyStroke | The keystroke. |
public static String getPrettyStringFor(KeyStroke keyStroke)
//package com.java2s; /*//ww w. j a v a 2 s.c om * 09/08/2005 * * UIUtil.java - Utility methods for org.fife.ui classes. * Copyright (C) 2005 Robert Futrell * http://fifesoft.com/rtext * Licensed under a modified BSD license. * See the included license file for details. */ import java.awt.event.KeyEvent; import javax.swing.KeyStroke; public class Main { /** * Returns a pretty string value for a KeyStroke, suitable for display as * the keystroke's value in a GUI. * * @param keyStroke The keystroke. * @return The string value of the keystroke. */ public static String getPrettyStringFor(KeyStroke keyStroke) { if (keyStroke == null) return ""; String string = KeyEvent.getKeyModifiersText(keyStroke.getModifiers()); if (string != null && string.length() > 0) string += "+"; int keyCode = keyStroke.getKeyCode(); if (keyCode != KeyEvent.VK_SHIFT && keyCode != KeyEvent.VK_CONTROL && keyCode != KeyEvent.VK_ALT && keyCode != KeyEvent.VK_META) string += KeyEvent.getKeyText(keyCode); return string; } }