当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.VK_CUT属性代码示例

本文整理汇总了Java中java.awt.event.KeyEvent.VK_CUT属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_CUT属性的具体用法?Java KeyEvent.VK_CUT怎么用?Java KeyEvent.VK_CUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.VK_CUT属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sortKeyStrokesByPreference

/**
 * Sort the list, so that the most appropriate accelerator is at index 0.
 */
private static List<KeyStroke[]> sortKeyStrokesByPreference(
        List<KeyStroke[]> keystrokes) {
    if (keystrokes.size() < 2) {
        return keystrokes;
    }
    KeyStroke best[] = null;
    boolean isSolaris =
            Utilities.getOperatingSystem() == Utilities.OS_SOLARIS;
    for (int i = 0; i < keystrokes.size(); i++) {
        KeyStroke[] ks = keystrokes.get(i);
        if (ks.length > 1) {
            continue;
        }
        boolean solarisKey = ks[0].getKeyCode() >= KeyEvent.VK_STOP
                && ks[0].getKeyCode() <= KeyEvent.VK_CUT;
        if (isSolaris == solarisKey
                && (best == null
                || best[0].getKeyCode() > ks[0].getKeyCode())) {
            //Solaris key on solaris OS or other key on other OS.
            best = ks;
        }
    }
    if (best != null) {
        keystrokes.remove(best);
        keystrokes.add(0, best);
    }
    return keystrokes;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:KeyStrokeUtils.java

示例2: keyPressed

@Override
public void keyPressed(KeyEvent e) {
	int ign = InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK;
	if ((e.getModifiersEx() & ign) != 0)
		return;
	switch (e.getKeyCode()) {
	case KeyEvent.VK_LEFT:
	case KeyEvent.VK_KP_LEFT:
		if (pos > 0)
			--pos;
		break;
	case KeyEvent.VK_RIGHT:
	case KeyEvent.VK_KP_RIGHT:
		if (pos < curText.length())
			++pos;
		break;
	case KeyEvent.VK_HOME:
		pos = 0;
		break;
	case KeyEvent.VK_END:
		pos = curText.length();
		break;
	case KeyEvent.VK_ESCAPE:
	case KeyEvent.VK_CANCEL:
		cancelEditing();
		break;
	case KeyEvent.VK_CLEAR:
		curText = "";
		pos = 0;
		break;
	case KeyEvent.VK_ENTER:
		stopEditing();
		break;
	case KeyEvent.VK_BACK_SPACE:
		if (pos > 0) {
			curText = curText.substring(0, pos - 1) + curText.substring(pos);
			--pos;
			field.setText(curText);
		}
		break;
	case KeyEvent.VK_DELETE:
		if (pos < curText.length()) {
			curText = curText.substring(0, pos) + curText.substring(pos + 1);
			field.setText(curText);
		}
		break;
	case KeyEvent.VK_INSERT:
	case KeyEvent.VK_COPY:
	case KeyEvent.VK_CUT:
	case KeyEvent.VK_PASTE:
		// TODO: enhance label editing
		break;
	default:
		; // ignore
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:56,代码来源:TextFieldCaret.java


注:本文中的java.awt.event.KeyEvent.VK_CUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。