本文整理匯總了Java中javax.swing.KeyStroke.isOnKeyRelease方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyStroke.isOnKeyRelease方法的具體用法?Java KeyStroke.isOnKeyRelease怎麽用?Java KeyStroke.isOnKeyRelease使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.KeyStroke
的用法示例。
在下文中一共展示了KeyStroke.isOnKeyRelease方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: keyCommand
import javax.swing.KeyStroke; //導入方法依賴的package包/類
/**
* Classes other than the Chatter itself may forward KeyEvents
* to the Chatter by using this method
*/
public void keyCommand(KeyStroke e) {
if ((e.getKeyCode() == 0 || e.getKeyCode() == KeyEvent.CHAR_UNDEFINED)
&& !Character.isISOControl(e.getKeyChar())) {
input.setText(input.getText() + e.getKeyChar());
}
else if (e.isOnKeyRelease()) {
switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER:
if (input.getText().length() > 0)
send(formatChat(input.getText()));
input.setText(""); //$NON-NLS-1$
break;
case KeyEvent.VK_BACK_SPACE:
case KeyEvent.VK_DELETE:
String s = input.getText();
if (s.length() > 0)
input.setText(s.substring(0, s.length() - 1));
break;
}
}
}
示例2: getAction
import javax.swing.KeyStroke; //導入方法依賴的package包/類
public Action getAction(final KeyStroke key) {
switch (key.getKeyCode()) {
case KeyEvent.VK_SHIFT:
case KeyEvent.VK_CONTROL:
case KeyEvent.VK_ALT:
case KeyEvent.VK_ALT_GRAPH:
case KeyEvent.VK_META:
case KeyEvent.VK_UNDEFINED:
case KeyEvent.CHAR_UNDEFINED:
// Not actually a bindable key press.
return null;
}
if (key.isOnKeyRelease()) {
// Again, not really our business here.
return null;
}
LOG.log(Level.FINE, "getAction {0}", key);
Map<KeyStroke,Binding> binder = bindings();
for (KeyStroke ctx : context) {
Binding sub = binder.get(ctx);
if (sub == null) {
resetContext();
return BROKEN; // no entry found after known prefix
}
binder = sub.nested;
if (binder == null) {
resetContext();
return BROKEN; // anomalous, expected to find submap here
}
}
Binding b = binder.get(key);
if (b == null) {
resetContext();
return null; // normal, not found
}
if (b.nested == null) {
resetContext();
return b.loadAction(); // found real action
} else {
return new AbstractAction() {
public void actionPerformed(ActionEvent e) {
shiftContext(key); // entering submap
}
};
}
}