本文整理汇总了Java中javax.swing.KeyStroke.toString方法的典型用法代码示例。如果您正苦于以下问题:Java KeyStroke.toString方法的具体用法?Java KeyStroke.toString怎么用?Java KeyStroke.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.KeyStroke
的用法示例。
在下文中一共展示了KeyStroke.toString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: putActionDelegate
import javax.swing.KeyStroke; //导入方法依赖的package包/类
private void putActionDelegate(InputMap map, KeyStroke ks) {
String binding = COPY_ACTION_DELEGATE+ks.toString();
Action action = getCopyActionDelegate(map, ks);
if (action != null) {
getActionMap().put(binding, action);
map.put(ks, binding);
}
}
示例2: getExpandKeyStrokeText
import javax.swing.KeyStroke; //导入方法依赖的package包/类
private static String getExpandKeyStrokeText(KeyStroke keyStroke) {
String expandKeyStrokeText;
if (keyStroke.equals(KeyStroke.getKeyStroke(' '))) { //NOI18N
expandKeyStrokeText = "SPACE"; // NOI18N
} else if (keyStroke.equals(KeyStroke.getKeyStroke(new Character(' '), InputEvent.SHIFT_MASK))) { //NOI18N
expandKeyStrokeText = "Shift-SPACE"; // NOI18N
} else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0))) {
expandKeyStrokeText = "TAB"; // NOI18N
} else if (keyStroke.equals(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0))) {
expandKeyStrokeText = "ENTER"; // NOI18N
} else {
expandKeyStrokeText = keyStroke.toString();
}
return expandKeyStrokeText;
}
示例3: getKeyStrokeText
import javax.swing.KeyStroke; //导入方法依赖的package包/类
/**
* Creates a {@code String} that keeps the attributes given
* {@code KeyStroke}. This {@code String} can be used to
* store the key stroke in an XML-file.
*
* @param keyStroke The {@code KeyStroke}.
* @return A {@code String} that produces a key stroke equal to the
* given {@code KeyStroke} if passed as a parameter to
* {@code getAWTKeyStroke(String)}.
*/
public static String getKeyStrokeText(KeyStroke keyStroke) {
return (keyStroke == null) ? "" : keyStroke.toString();
}