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


Java InputEvent.SHIFT_MASK屬性代碼示例

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


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

示例1: handleShortcut

@SuppressWarnings("deprecation")
boolean handleShortcut(KeyEvent e) {
    MenuShortcut s = new MenuShortcut(e.getKeyCode(),
                         (e.getModifiers() & InputEvent.SHIFT_MASK) > 0);
    MenuShortcut sE = new MenuShortcut(e.getExtendedKeyCode(),
                         (e.getModifiers() & InputEvent.SHIFT_MASK) > 0);
    // Fix For 6185151: Menu shortcuts of all menuitems within a menu
    // should be disabled when the menu itself is disabled
    if ((s.equals(shortcut) || sE.equals(shortcut)) && isItemEnabled()) {
        // MenuShortcut match -- issue an event on keydown.
        if (e.getID() == KeyEvent.KEY_PRESSED) {
            doMenuEvent(e.getWhen(), e.getModifiers());
        } else {
            // silently eat key release.
        }
        return true;
    }
    return false;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:MenuItem.java

示例2: mouseWheelMoved

public State mouseWheelMoved (Widget widget, WidgetMouseWheelEvent event) {
    JComponent view = widget.getScene ().getView ();
    Rectangle visibleRect = view.getVisibleRect ();
    int amount = event.getWheelRotation () * 64;

    switch (event.getModifiers () & (InputEvent.SHIFT_MASK | InputEvent.CTRL_MASK | InputEvent.ALT_MASK)) {
        case InputEvent.SHIFT_MASK:
            visibleRect.x += amount;
            break;
        case 0:
            visibleRect.y += amount;
            break;
        default:
            return State.REJECTED;
    }

    view.scrollRectToVisible (visibleRect);
    return State.CONSUMED;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:WheelPanAction.java

示例3: setOldModifiers

/**
 * Sets old modifiers by the new ones.
 */
private void setOldModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:DragSourceDragEvent.java

示例4: mapNewModifiers

@SuppressWarnings("deprecation")
private static int mapNewModifiers(int modifiers) {
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        modifiers |= InputEvent.SHIFT_MASK;
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) {
        modifiers |= InputEvent.ALT_MASK;
    }
    if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        modifiers |= InputEvent.ALT_GRAPH_MASK;
    }
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        modifiers |= InputEvent.CTRL_MASK;
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) != 0) {
        modifiers |= InputEvent.META_MASK;
    }

    return modifiers;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:AWTKeyStroke.java

示例5: addMouseListenerToHeaderInTable

public void addMouseListenerToHeaderInTable(JTable table) {
    final TableSorter sorter = this;
    final JTable tableView = table;
    tableView.setColumnSelectionAllowed(false);
    MouseAdapter listMouseListener = new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = tableView.convertColumnIndexToModel(viewColumn);
            if (e.getClickCount() == 1 && column != -1) {
                System.out.println("Sorting ...");
                int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
                boolean ascending = (shiftPressed == 0);
                sorter.sortByColumn(column, ascending);
            }
        }
    };
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(listMouseListener);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:TableSorter.java

示例6: menuItem

/** Construct a new JMenuItem then add it to an existing JMenu.
 * @param parent - the JMenu to add this JMenuItem into (or null if you don't want to add it to any JMenu yet)
 * @param label - the text to show on the menu
 * @param attrs - a list of attributes to apply onto the new JMenuItem
 * <p> If one positive number  a is supplied, we call setMnemonic(a)
 * <p> If two positive numbers a and b are supplied, and a!=VK_ALT, and a!=VK_SHIFT, we call setMnemoic(a) and setAccelerator(b)
 * <p> If two positive numbers a and b are supplied, and a==VK_ALT or a==VK_SHIFT, we call setAccelerator(a | b)
 * <p> If an ActionListener is supplied, we call addActionListener(x)
 * <p> If an Boolean x      is supplied, we call setEnabled(x)
 * <p> If an Icon x         is supplied, we call setIcon(x)
 */
public static JMenuItem menuItem (JMenu parent, String label, Object... attrs) {
   JMenuItem m = new JMenuItem(label, null);
   int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
   boolean hasMnemonic = false;
   for(Object x: attrs) {
      if (x instanceof Character || x instanceof Integer) {
         int k = (x instanceof Character) ? ((int)((Character)x)) : ((Integer)x).intValue();
         if (k < 0) continue;
         if (k==KeyEvent.VK_ALT)   { hasMnemonic = true; accelMask = accelMask | InputEvent.ALT_MASK;   continue; }
         if (k==KeyEvent.VK_SHIFT) { hasMnemonic = true; accelMask = accelMask | InputEvent.SHIFT_MASK; continue; }
         if (!hasMnemonic) { m.setMnemonic(k); hasMnemonic=true; } else m.setAccelerator(KeyStroke.getKeyStroke(k, accelMask));
      }
      if (x instanceof ActionListener) m.addActionListener((ActionListener)x);
      if (x instanceof Icon) m.setIcon((Icon)x);
      if (x instanceof Boolean) m.setEnabled((Boolean)x);
   }
   if (parent!=null) parent.add(m);
   return m;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:30,代碼來源:OurUtil.java

示例7: mapNewModifiers

private static int mapNewModifiers(int modifiers) {
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        modifiers |= InputEvent.SHIFT_MASK;
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) {
        modifiers |= InputEvent.ALT_MASK;
    }
    if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        modifiers |= InputEvent.ALT_GRAPH_MASK;
    }
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        modifiers |= InputEvent.CTRL_MASK;
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) != 0) {
        modifiers |= InputEvent.META_MASK;
    }

    return modifiers;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:AWTKeyStroke.java

示例8: setNewModifiers

/**
 * Sets new modifiers by the old ones.
 * The mouse modifiers have higher priority than overlaying key
 * modifiers.
 */
private void setNewModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:25,代碼來源:DragSourceDragEvent.java

示例9: setNewModifiers

/**
 * Sets new modifiers by the old ones.
 * The mouse modifiers have higher priority than overlaying key
 * modifiers.
 */
@SuppressWarnings("deprecation")
private void setNewModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:DragSourceDragEvent.java

示例10: mapOldModifiers

private static int mapOldModifiers(int modifiers) {
    if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
        modifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((modifiers & InputEvent.ALT_MASK) != 0) {
        modifiers |= InputEvent.ALT_DOWN_MASK;
    }
    if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
    }
    if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        modifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((modifiers & InputEvent.META_MASK) != 0) {
        modifiers |= InputEvent.META_DOWN_MASK;
    }

    modifiers &= InputEvent.SHIFT_DOWN_MASK
        | InputEvent.ALT_DOWN_MASK
        | InputEvent.ALT_GRAPH_DOWN_MASK
        | InputEvent.CTRL_DOWN_MASK
        | InputEvent.META_DOWN_MASK
        | InputEvent.BUTTON1_DOWN_MASK
        | InputEvent.BUTTON2_DOWN_MASK
        | InputEvent.BUTTON3_DOWN_MASK;

    return modifiers;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:AWTKeyStroke.java

示例11: keyPressed

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,代碼行數:14,代碼來源:ProfilingPointsWindowUI.java

示例12: keyPressed

public void keyPressed(KeyEvent e) {
    if ((e.getKeyCode() == KeyEvent.VK_CONTEXT_MENU)
            || ((e.getKeyCode() == KeyEvent.VK_F10) && (e.getModifiers() == InputEvent.SHIFT_MASK))) {
        int selectedRow = fieldsListTable.getSelectedRow();

        if (selectedRow != -1) {
            showPopupMenu(selectedRow, -1, -1);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:FieldsBrowserControllerUI.java

示例13: pressModifiers

/**
 * Presses modifiers keys by robot.
 *
 * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
 */
protected void pressModifiers(int modifiers) {
    if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
        pressKey(KeyEvent.VK_SHIFT, modifiers & ~InputEvent.SHIFT_MASK);
    } else if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        pressKey(KeyEvent.VK_ALT_GRAPH, modifiers & ~InputEvent.ALT_GRAPH_MASK);
    } else if ((modifiers & InputEvent.ALT_MASK) != 0) {
        pressKey(KeyEvent.VK_ALT, modifiers & ~InputEvent.ALT_MASK);
    } else if ((modifiers & InputEvent.META_MASK) != 0) {
        pressKey(KeyEvent.VK_META, modifiers & ~InputEvent.META_MASK);
    } else if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        pressKey(KeyEvent.VK_CONTROL, modifiers & ~InputEvent.CTRL_MASK);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:RobotDriver.java

示例14: processKeyEvent

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,代碼行數:10,代碼來源:HTMLTextArea.java

示例15: releaseModifiers

/**
 * Releases modifiers keys by robot.
 *
 * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
 */
protected void releaseModifiers(int modifiers) {
    if ((modifiers & InputEvent.SHIFT_MASK) != 0) {
        releaseKey(KeyEvent.VK_SHIFT, modifiers & ~InputEvent.SHIFT_MASK);
    } else if ((modifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        releaseKey(KeyEvent.VK_ALT_GRAPH, modifiers & ~InputEvent.ALT_GRAPH_MASK);
    } else if ((modifiers & InputEvent.ALT_MASK) != 0) {
        releaseKey(KeyEvent.VK_ALT, modifiers & ~InputEvent.ALT_MASK);
    } else if ((modifiers & InputEvent.META_MASK) != 0) {
        releaseKey(KeyEvent.VK_META, modifiers & ~InputEvent.META_MASK);
    } else if ((modifiers & InputEvent.CTRL_MASK) != 0) {
        releaseKey(KeyEvent.VK_CONTROL, modifiers & ~InputEvent.CTRL_MASK);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:RobotDriver.java


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