Java examples for Swing:JTable
Returns a pretty string value for a KeyStroke, suitable for display as the keystroke's value in a GUI.
/*// ww w . j av a 2 s . co m * 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. */ //package com.java2s; 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; } }