當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。