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


Java KeyEvent.getModifiers方法代码示例

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


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

示例1: keyTyped

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyTyped(KeyEvent e)
{
	Object o = e.getSource();
	if(o instanceof JTextField || o == enter || o == timeList)
	{
		int increment = ((e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK) ? -1 : 1;
		
		switch(e.getKeyChar())
		{
			case 'c':
			case 'C':
				cones.setText(Integer.toString(cones.getInt() + increment));
				e.consume();
				break;
			case 'g':
			case 'G':
				gates.setText(Integer.toString(gates.getInt() + increment));
				e.consume();
				break;
		}
	}
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:24,代码来源:TimeEntry.java

示例2: processKeyEvent

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
    public void processKeyEvent(KeyEvent evt) {
        if (evt.getID() == KeyEvent.KEY_TYPED) {
            Completion completion = Completion.get();
            switch (evt.getKeyChar()) {
                case ' ':
                    if (evt.getModifiers() == 0) {
                        completion.hideCompletion();
                        completion.hideDocumentation();
                    }
                    break;
//                case ';': //TODO, can special handling be added even if we press these buttons within a literal?
//                case ',':
//                case '(':
//                    completion.hideCompletion();
//                    completion.hideDocumentation();
//                case '.':
//                    if (defaultAction((JTextComponent) evt.getSource(), Character.toString(evt.getKeyChar()))) {
//                        evt.consume();
//                        break;
//                    }
            }
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:JPACompletionItem.java

示例3: keyTyped

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
    key = e.getKeyChar();
    if (key == (char) 127 || key == '\b' || key == '\n') {
        e.consume();
        return;
    }

    if (e.getModifiers() == KeyEvent.CTRL_MASK) {
        return;
    }

    palavra = insertChar(palavra, key);
    posCursor++;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:16,代码来源:MasterCli.java

示例4: handleShortcut

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
boolean handleShortcut(KeyEvent e) {
    // Is it a key event?
    int id = e.getID();
    if (id != KeyEvent.KEY_PRESSED && id != KeyEvent.KEY_RELEASED) {
        return false;
    }

    // Is the accelerator modifier key pressed?
    int accelKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
    if ((e.getModifiers() & accelKey) == 0) {
        return false;
    }

    // Pass MenuShortcut on to child menus.
    int nmenus = getMenuCount();
    for (int i = 0 ; i < nmenus ; i++) {
        Menu m = getMenu(i);
        if (m.handleShortcut(e)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:MenuBar.java

示例5: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent event) {

        tempPress = true;
        synchronized (tempLock) { tempLock.notifyAll(); }

        if (! startTest) {
            return;
        }
        for (int x = 0; x < inputMasks.length; x++) {
            if ((event.getModifiers() & inputMasks[x]) != 0) {
                System.out.println("Modifier set: " + event.getKeyModifiersText(inputMasks[x]));
                modifierStatus[x] = true;
            }
        }
        for (int x = 0; x < textKeys.length; x++) {
            if (event.getKeyCode() == textKeys[x]) {
                System.out.println("Text set: " + event.getKeyText(textKeys[x]));
                textStatus[x] = true;
            }
        }

        synchronized (keyLock) { keyLock.notifyAll(); }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:ModifierRobotEnhancedKeyTest.java

示例6: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {

    keyPressReceived = true;

    int code = e.getKeyCode();

    assertEQ(code, keyCode, "wrong key code");

    int mask = 0;

    if (code == KeyEvent.VK_SHIFT) {
        mask = InputEvent.SHIFT_MASK;
    } else if (code == KeyEvent.VK_CONTROL) {
        mask = InputEvent.CTRL_MASK;
    } else if (code == KeyEvent.VK_ALT) {
        mask = InputEvent.ALT_MASK;
    } else if (code == KeyEvent.VK_META) {
        mask = InputEvent.META_MASK;
    }

    int mod = e.getModifiers() & mask;
    assertEQ(mod, mask, "invalid key mask");

    synchronized (lock) { lock.notifyAll(); }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:KeyMaskTest.java

示例7: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int[] selectedRows = profilingPointsTable.getSelectedRows();

        if (selectedRows.length != 0) {
            Rectangle rowBounds = profilingPointsTable.getCellRect(selectedRows[0], 1, true);
            showProfilingPointsPopup(e.getComponent(), rowBounds.x + 20,
                                     rowBounds.y + (profilingPointsTable.getRowHeight() / 2));
        }
    } else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
        deletePPs();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ProfilingPointsWindowUI.java

示例8: processKeyEvent

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
protected void processKeyEvent(KeyEvent e) {
    int code = e.getKeyCode();
    if (code == KeyEvent.VK_CONTEXT_MENU ||
       (code == KeyEvent.VK_F10 && e.getModifiers() == InputEvent.SHIFT_MASK)) {
        e.consume();
        showPopupMenu(null);
    }
    
    super.processKeyEvent(e);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:HTMLTextArea.java

示例9: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/**
 * the key pressed event
 * @param event 
 */
@Override
public void keyPressed(KeyEvent event)
{
    if(event.getModifiers() != SHORTCUT_MASK && !(isDeadKey(event) && isActive) )
    {
        event.consume();
    }
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:13,代码来源:Console.java

示例10: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    assert (e.getSource() instanceof JTextField);

    if(((e.getModifiers() & (KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_MASK)) == 0) &&
            (e.getKeyCode() == KeyEvent.VK_DOWN || 
            e.getKeyCode() == KeyEvent.VK_UP ||
            e.getKeyCode() == KeyEvent.VK_ESCAPE)) {
        return ;
    }
    
    textField = (JTextField) e.getSource();
    KeyStroke keyStroke = createKeyStroke(e);

    boolean add = e.getKeyCode() != KeyEvent.VK_SHIFT &&
            e.getKeyCode() != KeyEvent.VK_CONTROL &&
            e.getKeyCode() != KeyEvent.VK_ALT &&
            e.getKeyCode() != KeyEvent.VK_META &&
            e.getKeyCode() != KeyEvent.VK_ALT_GRAPH;

    if (!(enterConfirms && keyStroke.equals(enterKS))) {
        if (keyStroke.equals(backspaceKS) && !key.equals("")) {
            // delete last key
            int i = key.lastIndexOf(' '); //NOI18N
            if (i < 0) {
                key = ""; //NOI18N
            } else {
                key = key.substring(0, i);
            }
            textField.setText(key);
        } else {
            // add key
            addKeyStroke(keyStroke, add);
        }

        e.consume();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ShortcutListener.java

示例11: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public synchronized void keyPressed(KeyEvent e) {
    if (   (e.getKeyCode() == KeyEvent.VK_ESCAPE && e.getModifiers() == 0) ||
           (e.getKeyCode() == KeyEvent.VK_ENTER  && e.getModifiers() == 0)
    ) {
        release(e.getKeyCode() == KeyEvent.VK_ESCAPE);
        e.consume();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:InstantRefactoringPerformer.java

示例12: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent evt) {
    if(evt.getKeyCode() == KeyEvent.VK_UP && (evt.getModifiers() & KeyEvent.ALT_MASK) == KeyEvent.ALT_MASK) {
        Action action = getChangeToParentDirectoryAction();
        action.actionPerformed(new ActionEvent(evt.getSource(), 0, ""));
        component.requestFocus();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DirectoryChooserUI.java

示例13: isCharForSearch

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
private boolean isCharForSearch (KeyEvent evt) {
    char ch = evt.getKeyChar();
    // refuse backspace key
    if ((int)ch == 8) {
        return false;
    }
    // #110975: refuse modifiers
    if (evt.getModifiers() != 0) {
        return false;
    }
    return (Character.isJavaIdentifierPart(ch) && !Character.isIdentifierIgnorable(ch)) 
            || Character.isSpaceChar(ch);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:DirectoryChooserUI.java

示例14: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent event) {
    // listens for enter key press on button
    if (event.getSource() == this && event.getModifiers() == 0 && event.getKeyCode() == KeyEvent.VK_ENTER) {
        event.consume();
        doClick();
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:9,代码来源:MButton.java

示例15: keyPressed

import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = classesListTable.getSelectedRow();

        if (selectedRow != -1) {
            Rectangle rowBounds = classesListTable.getCellRect(selectedRow, 0, true);
            showPopupMenu(selectedRow, rowBounds.x + (rowBounds.width / 2), rowBounds.y + (rowBounds.height / 2));
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ClassesListControllerUI.java


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