當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.getKeyLocation方法代碼示例

本文整理匯總了Java中java.awt.event.KeyEvent.getKeyLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.getKeyLocation方法的具體用法?Java KeyEvent.getKeyLocation怎麽用?Java KeyEvent.getKeyLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.getKeyLocation方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processKeyBinding

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
protected @Override boolean processKeyBinding(KeyStroke ks,
                                KeyEvent e,
                                int condition,
                                boolean pressed) {
    if (Utilities.isMac()) {
        int mods = e.getModifiers();
        boolean isCtrl = (mods & KeyEvent.CTRL_MASK) != 0;
        boolean isAlt = (mods & KeyEvent.ALT_MASK) != 0;
        if (isAlt && (e instanceof MarkedKeyEvent)) {
            mods = mods & ~ KeyEvent.CTRL_MASK;
            mods = mods & ~ KeyEvent.CTRL_DOWN_MASK;
            mods |= KeyEvent.ALT_MASK;
            mods |= KeyEvent.ALT_DOWN_MASK;
            
            KeyEvent newEvent = new MarkedKeyEvent (
                (Component) e.getSource(), e.getID(), 
                e.getWhen(), mods, e.getKeyCode(), e.getKeyChar(), 
                e.getKeyLocation());
            
            KeyStroke newStroke = null;
            if( null != ks ) {
                newStroke = e.getID() == KeyEvent.KEY_TYPED ?
                    KeyStroke.getKeyStroke (ks.getKeyChar(), mods) :
                    KeyStroke.getKeyStroke (ks.getKeyCode(), mods,
                    !ks.isOnKeyRelease());
            }
            
            boolean result = super.processKeyBinding (newStroke, 
                newEvent, condition, pressed);
            
            if (newEvent.isConsumed()) {
                e.consume();
            }
            return result;
        } else if (!isAlt) {
            return super.processKeyBinding (ks, e, condition, pressed);
        } else {
            return false;
        }
    } else {
        return super.processKeyBinding (ks, e, condition, pressed);
    }                     
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:44,代碼來源:MenuBar.java

示例2: createNew

import java.awt.event.KeyEvent; //導入方法依賴的package包/類
public KeyEvent createNew(KeyEvent old) {
    return new KeyEvent(component, old.getID(), old.getWhen(), old.getModifiers(), old.getKeyCode(),
            old.getKeyChar(), old.getKeyLocation());
}
 
開發者ID:Parabot,項目名稱:Parabot-317-API-Minified-OS-Scape,代碼行數:5,代碼來源:InternalKeyboard.java


注:本文中的java.awt.event.KeyEvent.getKeyLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。