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


Java KeyEvent.SHIFT_MASK属性代码示例

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


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

示例1: appendKeyMnemonic

public static String appendKeyMnemonic(StringBuilder sb, KeyStroke key) {
    String sk = org.openide.util.Utilities.keyToString(key);
    int mods = key.getModifiers();
    if ((mods & KeyEvent.CTRL_MASK) != 0) {
        sb.append("Ctrl+"); // NOI18N
    }
    if ((mods & KeyEvent.ALT_MASK) != 0) {
        sb.append("Alt+"); // NOI18N
    }
    if ((mods & KeyEvent.SHIFT_MASK) != 0) {
        sb.append("Shift+"); // NOI18N
    }
    if ((mods & KeyEvent.META_MASK) != 0) {
        sb.append("Meta+"); // NOI18N
    }

    int i = sk.indexOf('-'); //NOI18N
    if (i != -1) {
        sk = sk.substring(i + 1);
    }
    sb.append(sk);

    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:EditorActionUtilities.java

示例2: getString

/**
 * A plain text representation of a KeyStroke.  Doesn't differ much
 * from {@link KeyEvent#getKeyText}
 */
public static String getString(KeyStroke k) {
  if (k == null) {
    return null;
  }
  String s = KeyEvent.getKeyText(k.getKeyCode());
  s = s.replace(' ', '_');
  if ((k.getModifiers() & KeyEvent.SHIFT_MASK) > 0) {
    s = Resources.getString("Keys.shift") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
  }
  if ((k.getModifiers() & KeyEvent.CTRL_MASK) > 0) {
    s = Resources.getString("Keys.ctrl") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
  }
  if ((k.getModifiers() & KeyEvent.META_MASK) > 0) {
    s = Resources.getString("Keys.meta") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
  }
  if ((k.getModifiers() & KeyEvent.ALT_MASK) > 0) {
    s = Resources.getString("Keys.alt") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
  }
  return s.toUpperCase();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:24,代码来源:HotKeyConfigurer.java

示例3: getString

public static String getString(KeyStroke k) {
  String s = KeyEvent.getKeyText(k.getKeyCode());
  if ((k.getModifiers() & KeyEvent.SHIFT_MASK) > 0) {
    s = KeyEvent.getKeyText(KeyEvent.VK_SHIFT) + "+" + s;
  }
  if ((k.getModifiers() & KeyEvent.CTRL_MASK) > 0) {
    s = KeyEvent.getKeyText(KeyEvent.VK_CONTROL) + "+" + s;
  }
  if ((k.getModifiers() & KeyEvent.META_MASK) > 0) {
    s = KeyEvent.getKeyText(KeyEvent.VK_META) + "+" + s;
  }
  if ((k.getModifiers() & KeyEvent.ALT_MASK) > 0) {
    s = KeyEvent.getKeyText(KeyEvent.VK_ALT) + "+" + s;
  }
  return s;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:HotkeySpecifier.java

示例4: keyTyped

public State keyTyped (Widget widget, WidgetKeyEvent event) {
    boolean state = false;
    if (event.getKeyChar () == KeyEvent.VK_TAB) {
        if ((event.getModifiers () & KeyEvent.SHIFT_MASK) == KeyEvent.SHIFT_MASK)
            state = provider.switchPreviousFocus (widget);
        else
            state = provider.switchNextFocus (widget);
    }
    return state ? State.CONSUMED : State.REJECTED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CycleFocusAction.java

示例5: addModifiers

/** Adds characters for modifiers to the buffer.
* @param buf buffer to add to
* @param modif modifiers to add (KeyEvent.XXX_MASK)
* @return true if something has been added
*/
private static boolean addModifiers(StringBuilder buf, int modif) {
    boolean b = false;

    if ((modif & KeyEvent.CTRL_MASK) != 0) {
        buf.append("C"); // NOI18N
        b = true;
    }

    if ((modif & KeyEvent.ALT_MASK) != 0) {
        buf.append("A"); // NOI18N
        b = true;
    }

    if ((modif & KeyEvent.SHIFT_MASK) != 0) {
        buf.append("S"); // NOI18N
        b = true;
    }

    if ((modif & KeyEvent.META_MASK) != 0) {
        buf.append("M"); // NOI18N
        b = true;
    }

    if ((modif & CTRL_WILDCARD_MASK) != 0) {
        buf.append("D");
        b = true;
    }

    if ((modif & ALT_WILDCARD_MASK) != 0) {
        buf.append("O");
        b = true;
    }

    return b;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:Utilities.java

示例6: addModifiersPortable

private static boolean addModifiersPortable(StringBuilder buf, int modifiers) {
    boolean b = false;

    if ((modifiers & KeyEvent.SHIFT_MASK) != 0) {
        buf.append('S');
        b = true;
    }

    if (Utilities.isMac() && ((modifiers & KeyEvent.META_MASK) != 0) || !Utilities.isMac() && ((modifiers & KeyEvent.CTRL_MASK) != 0)) {
        buf.append('D');
        b = true;
    }

    if (Utilities.isMac() && ((modifiers & KeyEvent.CTRL_MASK) != 0) || !Utilities.isMac() && ((modifiers & KeyEvent.ALT_MASK) != 0)) {
        buf.append('O');
        b = true;
    }
    // mac alt fallback
    if (Utilities.isMac() && ((modifiers & KeyEvent.ALT_MASK) != 0)) {
        buf.append('A');
        b = true;
    }
    // META fallback, see issue #224362
    if (!Utilities.isMac() && ((modifiers & KeyEvent.META_MASK) != 0)) {
        buf.append('M');
        b = true;
    }

    return b;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:Utilities.java

示例7: actionPerformed

public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);

    try {
        Container con = TreeTable.this.getFocusCycleRootAncestor();

        if (con != null) {
            Component target = TreeTable.this;

            if (getParent() instanceof JViewport) {
                target = getParent().getParent();

                if (target == con) {
                    target = TreeTable.this;
                }
            }

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;

            if (eo instanceof KeyEvent) {
                backward = ((((KeyEvent) eo).getModifiers() & KeyEvent.SHIFT_MASK) != 0) &&
                    ((((KeyEvent) eo).getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0);
            }

            Component to = backward ? con.getFocusTraversalPolicy().getComponentAfter(con, TreeTable.this)
                                    : con.getFocusTraversalPolicy().getComponentAfter(con, TreeTable.this);

            if (to == TreeTable.this) {
                to = backward ? con.getFocusTraversalPolicy().getFirstComponent(con)
                              : con.getFocusTraversalPolicy().getLastComponent(con);
            }

            to.requestFocus();
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:TreeTable.java

示例8: actionPerformed

public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);

    try {
        Container con = BaseTable.this.getFocusCycleRootAncestor();

        if (con != null) {
            Component target = BaseTable.this;

            if (getParent() instanceof JViewport) {
                target = getParent().getParent();

                if (target == con) {
                    target = BaseTable.this;
                }
            }

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;

            if (eo instanceof KeyEvent) {
                backward = ((((KeyEvent) eo).getModifiers() & KeyEvent.SHIFT_MASK) != 0) &&
                    ((((KeyEvent) eo).getModifiersEx() & KeyEvent.SHIFT_DOWN_MASK) != 0);
            }

            Component to = backward ? con.getFocusTraversalPolicy().getComponentAfter(con, BaseTable.this)
                                    : con.getFocusTraversalPolicy().getComponentAfter(con, BaseTable.this);

            if (to == BaseTable.this) {
                to = backward ? con.getFocusTraversalPolicy().getFirstComponent(con)
                              : con.getFocusTraversalPolicy().getLastComponent(con);
            }

            to.requestFocus();
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:BaseTable.java

示例9: keyPressed

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,代码行数:37,代码来源:ShortcutListener.java

示例10: processKeyEvent

/** Overridden to allow standard keybinding processing of VK_TAB and
 * abort any pending drag operation on the vertical grid. */
public void processKeyEvent(KeyEvent e) {
    if (dragListener.isArmed()) {
        dragListener.setArmed(false);
    }

    boolean suppressDefaultHandling = ((searchField != null) && searchField.isShowing()) &&
        ((e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN));

    //Manually hook in the bindings for tab - does not seem to get called
    //automatically
    if (e.getKeyCode() != e.VK_TAB) {
        if (!suppressDefaultHandling) {
            //Either the search field or the table should handle up/down, not both
            super.processKeyEvent(e);
        }

        if (!e.isConsumed()) {
            if ((e.getID() == KeyEvent.KEY_PRESSED) && !isEditing()) {
                int modifiers = e.getModifiers();
                int keyCode = e.getKeyCode();

                if (((modifiers > 0) && (modifiers != KeyEvent.SHIFT_MASK)) || e.isActionKey()) {
                    return;
                }

                char c = e.getKeyChar();

                if (!Character.isISOControl(c) && (keyCode != KeyEvent.VK_SHIFT) &&
                        (keyCode != KeyEvent.VK_ESCAPE)) {
                    searchArmed = true;
                    e.consume();
                }
            } else if (searchArmed && (e.getID() == KeyEvent.KEY_TYPED)) {
                passToSearchField(e);
                e.consume();
                searchArmed = false;
            } else {
                searchArmed = false;
            }
        }
    } else {
        processKeyBinding(
            KeyStroke.getKeyStroke(e.VK_TAB, e.getModifiersEx(), e.getID() == e.KEY_RELEASED), e,
            JComponent.WHEN_FOCUSED, e.getID() == e.KEY_PRESSED
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:49,代码来源:BaseTable.java

示例11: actionPerformed

@Override
public void actionPerformed(ActionEvent e) {
    setFocusCycleRoot(false);
    try {
        Container con = ETable.this.getFocusCycleRootAncestor();
        if (con != null) {
            /*
            Component target = ETable.this;
            if (getParent() instanceof JViewport) {
                target = getParent().getParent();
                if (target == con) {
                    target = ETable.this;
                }
            }
            */

            EventObject eo = EventQueue.getCurrentEvent();
            boolean backward = false;
            if (eo instanceof KeyEvent) {
                backward = 
                    (((KeyEvent) eo).getModifiers() 
                    & KeyEvent.SHIFT_MASK) 
                    != 0 && (((KeyEvent) eo).getModifiersEx() & 
                    KeyEvent.SHIFT_DOWN_MASK) != 0;
            }

            Component c = ETable.this;
            Component to;
            Container parentWithFTP = null;
            do {
                FocusTraversalPolicy ftp = con.getFocusTraversalPolicy();
                to = backward ? ftp.getComponentBefore(con, c)
                              : ftp.getComponentAfter(con, c);


                if (to == ETable.this) {
                    to = backward ? ftp.getFirstComponent(con)
                                  : ftp.getLastComponent(con);
                }
                if (to == ETable.this) {
                    parentWithFTP = con.getParent();
                    if (parentWithFTP != null) {
                        parentWithFTP = parentWithFTP.getFocusCycleRootAncestor();
                    }
                    if (parentWithFTP != null) {
                        c = con;
                        con = parentWithFTP;
                    }
                }
            } while (to == ETable.this && parentWithFTP != null);
            if (to != null) {
                to.requestFocus();
            }
        }
    } finally {
        setFocusCycleRoot(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:ETable.java

示例12: actionPerformed

@Override
public void actionPerformed(ActionEvent evt) {
    boolean editors = true;
    boolean views = !documentsOnly;
    if( "immediately".equals( evt.getActionCommand() ) ) {
        TopComponent activeTc = TopComponent.getRegistry().getActivated();
        if( null != activeTc ) {
            if( TopComponentTracker.getDefault().isEditorTopComponent( activeTc ) ) {
                //switching in a document, go to some other document
                views = false;
            } else {
                //switching in a view, go to some other view
                editors = false;
                views = true;
            }
        }
    }
    
    TopComponent[] documents = getRecentWindows(editors, views);
    
    if (documents.length < 2) {
        return;
    }
    
    if(!"immediately".equals(evt.getActionCommand()) && // NOI18N
            !(evt.getSource() instanceof javax.swing.JMenuItem)) {
        // #46800: fetch key directly from action command
        KeyStroke keyStroke = Utilities.stringToKey(evt.getActionCommand());
        
        if(keyStroke != null) {
            int triggerKey = keyStroke.getKeyCode();
            int reverseKey = KeyEvent.VK_SHIFT;
            int releaseKey = 0;
            
            int modifiers = keyStroke.getModifiers();
            if((InputEvent.CTRL_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_CONTROL;
            } else if((InputEvent.ALT_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_ALT;
            } else if((InputEvent.META_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_META;
            }
            
            if(releaseKey != 0) {
                if (!KeyboardPopupSwitcher.isShown()) {
                    KeyboardPopupSwitcher.showPopup(documentsOnly, releaseKey, triggerKey, (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0);
                }
                return;
            }
        }
    }

    int documentIndex = (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0 ? 1 : documents.length-1;
    TopComponent tc = documents[documentIndex];
    // #37226 Unmaximized the other mode if needed.
    WindowManagerImpl wm = WindowManagerImpl.getInstance();
    ModeImpl mode = (ModeImpl) wm.findMode(tc);
    if(mode != null && mode != wm.getCurrentMaximizedMode()) {
        wm.switchMaximizedMode(null);
    }
    
    tc.requestActive();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:RecentViewListAction.java

示例13: actionPerformed

@Override
public void actionPerformed(ActionEvent evt) {
    List<DVThread> threads = getThreads();
    int threadsCount = threads.size();
    if (threadsCount < 1) {
        Toolkit.getDefaultToolkit().beep();
        return;
    }
    
    if(!"immediately".equals(evt.getActionCommand()) && // NOI18N
            !(evt.getSource() instanceof javax.swing.JMenuItem)) {
        // #46800: fetch key directly from action command
        KeyStroke keyStroke = Utilities.stringToKey(evt.getActionCommand());
        
        if(keyStroke != null) {
            int triggerKey = keyStroke.getKeyCode();
            int releaseKey = 0;
            
            int modifiers = keyStroke.getModifiers();
            if((InputEvent.CTRL_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_CONTROL;
            } else if((InputEvent.ALT_MASK & modifiers) != 0) {
                releaseKey = KeyEvent.VK_ALT;
            } else if((InputEvent.META_MASK & modifiers) != 0) {
                releaseKey = InputEvent.META_MASK;
            }
            
            if(releaseKey != 0) {
                if (!KeyboardPopupSwitcher.isShown()) {
                    KeyboardPopupSwitcher.selectItem(
                            createSwitcherItems(threads),
                            releaseKey, triggerKey, true, true); // (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0
                }
                return;
            }
        }
    }
    
    if (threadsCount == 1) {
        threads.get(0).makeCurrent();
    } else {
        int index = (evt.getModifiers() & KeyEvent.SHIFT_MASK) == 0 ? 1 : threadsCount - 1;
        threads.get(index).makeCurrent();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:ThreadsHistoryAction.java

示例14: readModifiers

/** Reads for modifiers and creates integer with required mask.
* @param s string with modifiers
* @return integer with mask
* @exception NoSuchElementException if some letter is not modifier
*/
private static int readModifiers(String s) throws NoSuchElementException {
    int m = 0;

    for (int i = 0; i < s.length(); i++) {
        switch (s.charAt(i)) {
        case 'C':
            m |= KeyEvent.CTRL_MASK;

            break;

        case 'A':
            m |= KeyEvent.ALT_MASK;

            break;

        case 'M':
            m |= KeyEvent.META_MASK;

            break;

        case 'S':
            m |= KeyEvent.SHIFT_MASK;

            break;

        case 'D':
            m |= CTRL_WILDCARD_MASK;

            break;

        case 'O':
            m |= ALT_WILDCARD_MASK;

            break;

        default:
            throw new NoSuchElementException(s);
        }
    }

    return m;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:Utilities.java


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