java.awt.event.KeyEvent.isActionKey()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中java.awt.event.KeyEvent.isActionKey()方法的一些代码示例,展示了KeyEvent.isActionKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyEvent.isActionKey()方法的具体详情如下:
包路径:java.awt.event.KeyEvent
类名称:KeyEvent
方法名:isActionKey

KeyEvent.isActionKey介绍

[英]Returns whether the key in this event is an "action" key. Typically an action key does not fire a unicode character and is not a modifier key.
[中]返回此事件中的键是否为“操作”键。通常,操作键不会触发unicode字符,也不是修改键。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-awt

@Override
  public void keyTyped(KeyEvent e) {
    int modifiers = e.getModifiers();
    int keyCode = e.getKeyCode();
    char c = e.getKeyChar();
    //#43617 - don't eat + and -
    //#98634 - and all its duplicates dont't react to space
    if ((c == '+') || (c == '-') || (c==' ')) return; // NOI18N
    if (((modifiers > 0) && (modifiers != KeyEvent.SHIFT_MASK)) || e.isActionKey()) {
      return;
    }
    if (Character.isISOControl(c) ||
        (keyCode == KeyEvent.VK_SHIFT) ||
        (keyCode == KeyEvent.VK_ESCAPE)) return;
    displaySearchField();
    
    final KeyStroke stroke = KeyStroke.getKeyStrokeForEvent(e);
    searchTextField.setText(String.valueOf(stroke.getKeyChar()));
    e.consume();
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

/**
 * @see KeyEvent
 */
public boolean isActionKey() {
  return event.isActionKey();
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

/**
 * @see KeyEvent
 */
public boolean isActionKey() {
  return event.isActionKey();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

private void filterComboKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_filterComboKeyPressed
  if (!evt.isActionKey() && ("" + evt.getKeyChar()).trim().length()!=0 && evt.getKeyChar()!='\uffff') {
    searchPanel.setVisible(true);
    searchField.requestFocus();
    searchField.setText("" + evt.getKeyChar());
  }
}//GEN-LAST:event_filterComboKeyPressed

代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker

@Override
public void keyReleased(KeyEvent e) {
  if (e.isActionKey() && e.getKeyCode() == KeyEvent.VK_UP) {
    e.consume();
    upPressed = false;
    increaseTimer.stop();
  }
  if (e.isActionKey() && e.getKeyCode() == KeyEvent.VK_DOWN) {
    e.consume();
    decreaseTimer.stop();
    downPressed = false;
  }
}

代码示例来源:origin: org.piccolo2d/piccolo2d-core

/**
 * Returns whether the key event involves the action key.
 * 
 * @return true if key involved is the action key
 */
public boolean isActionKey() {
  if (isKeyEvent()) {
    final KeyEvent e = (KeyEvent) inputEvent;
    return e.isActionKey();
  }
  throw new IllegalStateException("Can't get isActionKey from mouse event");
}

代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql

private void onKeyTyped(KeyEvent e)
{
 if(false == e.isActionKey())
 {
   _parserTimer.restart();
 }
}

代码示例来源:origin: in.jlibs/org-netbeans-swing-outline

@Override
public void keyPressed(KeyEvent e) {
  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) {
    armed = true;
    e.consume();
  }
}
@Override

代码示例来源:origin: realXuJiang/bigtable-sql

private void onKeyTyped(KeyEvent e)
{
 if(false == e.isActionKey())
 {
   _parserTimer.restart();
 }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
  public void keyPressed(KeyEvent e) {
    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)) {
      searchTextField.setText(String.valueOf(c));
      displaySearchField();
    }
  }
}

代码示例来源:origin: freeplane/freeplane

private boolean isActionEvent(final KeyEvent e) {
  return e.isActionKey() || isControlCharacter(e.getKeyChar());
}

代码示例来源:origin: Multibit-Legacy/multibit-hd

public void keyReleased(KeyEvent ke) {
  // Prevent action keys (navigation etc) from triggering changes
  if (ke.isActionKey() || ke.getKeyCode() == KeyEvent.VK_TAB) {
   return;
  }
  // Must be user key press to be here
  // Invoke a new EDT operation to avoid slowing the keyboard down
  SwingUtilities.invokeLater(new Runnable() {
   @Override
   public void run() {
    String enteredText = textField.getText();
    // Use the entered text to update the available popup items
    T[] popupItems = filter.update(enteredText);
    if (popupItems.length == 0) {
     // Nothing to show
     comboBox.hidePopup();
    } else {
     // Popup contains items
     // Update the model to reflect the new items (fires setItem() in editor)
     comboBox.setModel(new DefaultComboBoxModel<>(popupItems));
     // Update the selected item with the text to allow edits
     comboBox.setSelectedItem(enteredText);
     // Ensure that the popup is showing
     comboBox.showPopup();
    }
   }
  });
 }
};

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

private void contactJListKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_contactJListKeyPressed
  if (evt.getKeyCode()==KeyEvent.VK_ENTER) {
    ((ContactListItem) contactJList.getSelectedValue()).openChat();
  } else if (evt.getKeyCode()==KeyEvent.VK_ESCAPE) {
    contactJList.requestFocus();
    searchPanel.setVisible(false);
    searchField.setText("");
  } else if (!evt.isActionKey() && ("" + evt.getKeyChar()).trim().length()!=0 && evt.getKeyChar()!='\uffff') {
    searchPanel.setVisible(true);
    searchField.requestFocus();
    searchField.setText(""+evt.getKeyChar());
  } 
}//GEN-LAST:event_contactJListKeyPressed

代码示例来源:origin: org.jclarion/clarion-runtime

private boolean isActionKey(KeyEvent e)
{
  if ((e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK)!=0) return true;
  
  if (e.getKeyChar()!=KeyEvent.CHAR_UNDEFINED) {
    if (e.getKeyChar()=='\n') return true;
    return false;
  } else {
    if (e.getKeyCode()=='\n' && e.getModifiersEx()==0) return true;
    return e.isActionKey();
  }
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

public void keyPressed(KeyEvent keyEvent) {
    // don't popup on action keys (cursor movements, etc...)
    if (keyEvent.isActionKey()) return;
    // don't popup if the combobox isn't visible anyway
    if (comboBox.isDisplayable() && !comboBox.isPopupVisible()) {
      int keyCode = keyEvent.getKeyCode();
      // don't popup when the user hits shift,ctrl or alt
      if (keyCode==KeyEvent.VK_SHIFT || keyCode==KeyEvent.VK_CONTROL || keyCode==KeyEvent.VK_ALT) return;
      // don't popup when the user hits escape (see issue #311)
      if (keyCode==KeyEvent.VK_ENTER || keyCode==KeyEvent.VK_ESCAPE) return;
      comboBox.setPopupVisible(true);
    }
  }
};

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
  public void keyPressed(KeyEvent keyEvent) {
    // don't popup on action keys (cursor movements, etc...)
    if (keyEvent.isActionKey()) {
      return;
    }
    
    // don't popup if the combobox isn't visible anyway
    if (comboBox.isDisplayable() && !comboBox.isPopupVisible()) {
      int keyCode = keyEvent.getKeyCode();
      // don't popup when the user hits shift,ctrl or alt
      if (keyCode==KeyEvent.VK_SHIFT || keyCode==KeyEvent.VK_CONTROL || keyCode==KeyEvent.VK_ALT) return;
      // don't popup when the user hits escape (see issue #311)
      if (keyCode==KeyEvent.VK_ENTER || keyCode==KeyEvent.VK_ESCAPE) return;
      comboBox.setPopupVisible(true);
    }
  }
}

代码示例来源:origin: tmyroadctfig/swingx

@Override
  public void keyPressed(KeyEvent keyEvent) {
    // don't popup on action keys (cursor movements, etc...)
    if (keyEvent.isActionKey()) {
      return;
    }
    
    // don't popup if the combobox isn't visible anyway
    if (comboBox.isDisplayable() && !comboBox.isPopupVisible()) {
      int keyCode = keyEvent.getKeyCode();
      // don't popup when the user hits shift,ctrl or alt
      if (keyCode==KeyEvent.VK_SHIFT || keyCode==KeyEvent.VK_CONTROL || keyCode==KeyEvent.VK_ALT) return;
      // don't popup when the user hits escape (see issue #311)
      if (keyCode==KeyEvent.VK_ENTER || keyCode==KeyEvent.VK_ESCAPE) return;
      comboBox.setPopupVisible(true);
    }
  }
}

代码示例来源:origin: freeplane/freeplane

private boolean editCell(final KeyStroke ks, final KeyEvent e) {
  if (isFocusOwner() && ks.getKeyCode() != KeyEvent.VK_TAB
      && e != null && e.getID() == KeyEvent.KEY_PRESSED && !e.isActionKey()
      && e.getKeyChar() != KeyEvent.CHAR_UNDEFINED
      && 0 == (e.getModifiers() & (InputEvent.CTRL_MASK | InputEvent.ALT_MASK))) {
    final int leadRow = getSelectionModel().getLeadSelectionIndex();
    final int leadColumn = getColumnModel().getSelectionModel().getLeadSelectionIndex();
    if (leadRow == -1 || leadColumn == -1  || isEditing() || !editCellAt(leadRow, leadColumn, e)) {
        return false;
    }
    return true;
  }
  return false;
}

代码示例来源:origin: BaseXdb/basex

@Override
public void keyReleased(final KeyEvent e) {
 final boolean exec = gui.editor.go.isEnabled();
 if(EXEC1.is(e)) {
  if(exec) release(Action.EXECUTE);
 } else if(UNIT.is(e)) {
  if(exec) release(Action.TEST);
 } else if((!e.isActionKey() || MOVEDOWN.is(e) || MOVEUP.is(e)) && !modifier(e)) {
  release(Action.CHECK);
 }
}

代码示例来源:origin: org.basex/basex

@Override
public void keyReleased(final KeyEvent e) {
 final boolean exec = gui.editor.go.isEnabled();
 if(EXEC1.is(e)) {
  if(exec) release(Action.EXECUTE);
 } else if(UNIT.is(e)) {
  if(exec) release(Action.TEST);
 } else if((!e.isActionKey() || MOVEDOWN.is(e) || MOVEUP.is(e)) && !modifier(e)) {
  release(Action.CHECK);
 }
}

相关文章