本文整理汇总了Java中java.awt.event.KeyEvent.VK_UP属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_UP属性的具体用法?Java KeyEvent.VK_UP怎么用?Java KeyEvent.VK_UP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_UP属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyTyped
@Override
public void keyTyped(KeyEvent ke) {
if(ke.getSource() == frame.getjList1()) {
if(ke.getKeyCode() == KeyEvent.VK_UP ||
ke.getKeyCode() == KeyEvent.VK_DOWN ||
ke.getKeyCode() == KeyEvent.VK_ENTER ||
ke.getKeyCode() == KeyEvent.VK_CONTROL) {
return;
} else {
int selection = frame.getjList1().getSelectedIndex();
for(int i = 0; i < pane.getKeyListeners().length; ++i) {
if(pane.getKeyListeners()[i] != this)
pane.getKeyListeners()[i].keyTyped(ke);
}
giveMenuOptions();
ke.consume();
frame.getjList1().setSelectedIndex(selection);
}
}
}
示例2: bufferBiasTextFieldKeyPressed
private void bufferBiasTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_bufferBiasTextFieldKeyPressed
// key pressed in text field
// System.out.println("keyPressed evt "+evt);
// System.out.println("value field key pressed");
int code = evt.getKeyCode();
boolean shifted = evt.isShiftDown();
float byRatio = 1.02f;
if (code == KeyEvent.VK_UP) {
startEdit();
if (shifted) {
pot.setBufferBitValue(pot.getBufferBitValue() + 1);
} else {
pot.changeBufferBiasByRatio(byRatio);
}
endEdit();
} else if (code == KeyEvent.VK_DOWN) {
startEdit();
if (shifted) {
pot.setBufferBitValue(pot.getBufferBitValue() - 1);
} else {
pot.changeBufferBiasByRatio(1f / byRatio);
}
endEdit();
}
}
示例3: checkInput
public void checkInput() {
KeyEvent event = buffer.pop();
if (event != null){
if (event.getID() == java.awt.event.KeyEvent.KEY_PRESSED){
switch(event.getKeyCode()) {
case KeyEvent.VK_UP:
snake.setDirection('U');
break;
case KeyEvent.VK_DOWN:
snake.setDirection('D');
break;
case KeyEvent.VK_LEFT:
snake.setDirection('L');
break;
case KeyEvent.VK_RIGHT:
snake.setDirection('R');
break;
}
}
//System.out.println(event.getKeyCode());
}
buffer.clear();
}
示例4: commandKeyPressed
private void commandKeyPressed(java.awt.event.KeyEvent evt) {
if (evt.getKeyCode()==KeyEvent.VK_DOWN) {
if(displayer.isVisible()) {
displayer.selectNext();
evt.consume();
}
} else if (evt.getKeyCode() == KeyEvent.VK_UP) {
if(displayer.isVisible()) {
displayer.selectPrev();
evt.consume();
}
} else if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
if(displayer.isVisible()) {
evt.consume();
invokeSelectedItem();
}
} else if ((evt.getKeyCode()) == KeyEvent.VK_ESCAPE) {
if(displayer.isVisible()) {
returnFocus();
displayer.clearModel();
requestFocus();
evt.consume();
}
}
}
示例5: listKeyPressed
private void listKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_listKeyPressed
// UP / DOWN just wraps around the list
// TODO: convert to action & bind to action map
int index = list.getSelectedIndex();
if (evt.getKeyCode() == KeyEvent.VK_UP) {
list.setSelectedIndex(index == 0 ? model.getSize() - 1 : index - 1);
}
if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
list.setSelectedIndex(index == (model.getSize() - 1) ? 0 : index + 1);
}
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
if (!list.isSelectionEmpty()) {
itemSelected(list.getSelectedIndex());
}
}
evt.consume();
}
示例6: keyPressed
public void keyPressed(KeyEvent e) {
int i = targetList.getSelectedIndex();
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
i = targetList.getSelectedIndex() - 1;
if (i < 0) {
i = 0;
}
targetList.setSelectedIndex(i);
break;
case KeyEvent.VK_DOWN:
int listSize = targetList.getModel().getSize();
i = targetList.getSelectedIndex() + 1;
if (i >= listSize) {
i = listSize - 1;
}
targetList.setSelectedIndex(i);
break;
default:
break;
}
}
示例7: performAction
public static void performAction(Node[] nodes, int keyCode) {
int dimension = (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT)
? LayoutConstants.HORIZONTAL : LayoutConstants.VERTICAL;
int direction = (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_UP)
? LayoutConstants.LEADING : LayoutConstants.TRAILING;
duplicate(nodes, dimension, direction);
}
示例8: coarseBiasTextFieldKeyPressed
private void coarseBiasTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_coarseBiasTextFieldKeyPressed
int code = evt.getKeyCode();
if (code == KeyEvent.VK_UP) {
startEdit();
dontProcessCoarseBiasSlider=true;
pot.setCoarseBitValue(pot.getCoarseBitValue() - 1);
endEdit();
} else if (code == KeyEvent.VK_DOWN) {
dontProcessCoarseBiasSlider=true;
startEdit();
pot.setCoarseBitValue(pot.getCoarseBitValue() + 1);
endEdit();
}
// log.info(pot.toString());
}
示例9: keyReleased
public void keyReleased(java.awt.event.KeyEvent evt) {
if(!isInteger()) return;
int key = evt.getKeyCode();
int step = 0;
if(key == KeyEvent.VK_UP || key == KeyEvent.VK_RIGHT) step = 1;
else if(key == KeyEvent.VK_DOWN || key == KeyEvent.VK_LEFT) step = -1;
if(step == 0) return;
int i = Integer.parseInt(textField.getText()) + step;
textField.setText(Integer.toString(i));
updateValue();
}
示例10: keyReleased
@Override
public void keyReleased(KeyEvent arg0) {
// TODO Auto-generated method stub
int keyCode = arg0.getKeyCode();
if(keyCode == KeyEvent.VK_RIGHT){
player.setRight(false);
}
if(keyCode == KeyEvent.VK_LEFT){
player.setLeft(false);
}
if(keyCode == KeyEvent.VK_UP){
player.setUp(false);
}
if(keyCode == KeyEvent.VK_DOWN){
player.setDown(false);
}
if(keyCode == KeyEvent.VK_SPACE){
player.setAttacking(false);
}
if(keyCode == KeyEvent.VK_ESCAPE) {
setVisible(false);
f.getContentPane().removeAll();
f.setVisible(false);
new Menu();
}
}
示例11: keySet
public static void keySet(int i, boolean b) {
if(i == KeyEvent.VK_UP) keyState[UP] = b;
else if(i == KeyEvent.VK_LEFT) keyState[LEFT] = b;
else if(i == KeyEvent.VK_DOWN) keyState[DOWN] = b;
else if(i == KeyEvent.VK_RIGHT) keyState[RIGHT] = b;
else if(i == KeyEvent.VK_W) keyState[BUTTON1] = b;
else if(i == KeyEvent.VK_E) keyState[BUTTON2] = b;
else if(i == KeyEvent.VK_R) keyState[BUTTON3] = b;
else if(i == KeyEvent.VK_F) keyState[BUTTON4] = b;
else if(i == KeyEvent.VK_ENTER) keyState[ENTER] = b;
else if(i == KeyEvent.VK_ESCAPE) keyState[ESCAPE] = b;
}
示例12: fineBiasTextFieldKeyPressed
private void fineBiasTextFieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_fineBiasTextFieldKeyPressed
// key pressed in text field
// System.out.println("keyPressed evt "+evt);
// System.out.println("value field key pressed");
int code = evt.getKeyCode();
if (code == KeyEvent.VK_UP) {
startEdit();
pot.setFineBitValue(pot.getFineBitValue() + 1);
endEdit();
} else if (code == KeyEvent.VK_DOWN) {
startEdit();
pot.setFineBitValue(pot.getFineBitValue() - 1);
endEdit();
}
}
示例13: keyPressed
public void keyPressed(KeyEvent event) {
int code = event.getKeyCode();
switch (code) {
case KeyEvent.VK_TAB:
completeAction(event);
break;
case KeyEvent.VK_LEFT:
case KeyEvent.VK_BACK_SPACE:
backAction(event);
break;
case KeyEvent.VK_UP:
upAction(event);
break;
case KeyEvent.VK_DOWN:
downAction(event);
break;
case KeyEvent.VK_ENTER:
enterAction(event);
break;
case KeyEvent.VK_HOME:
event.consume();
area.setCaretPosition(startPos);
break;
case KeyEvent.VK_D:
if ((event.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) != 0) {
event.consume();
inputJoin.send(Channel.LINE, EMPTY_LINE);
}
break;
}
if (completePopup.isVisible() && code != KeyEvent.VK_TAB
&& code != KeyEvent.VK_UP && code != KeyEvent.VK_DOWN)
completePopup.setVisible(false);
}
示例14: keyPressed
@Override
public void keyPressed(KeyEvent e) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("BookmarkHistoryPopup.keyPressed: e=" + e + '\n');
}
int keyCode = e.getKeyCode();
if (gotoPreviousKeyStroke != null && gotoPreviousKeyStroke.getKeyCode() == keyCode) {
e.consume();
selectPrevious();
} else if (gotoNextKeyStroke != null && gotoNextKeyStroke.getKeyCode() == keyCode) {
e.consume();
selectNext();
} else {
switch (keyCode) {
case KeyEvent.VK_ENTER:
BookmarkInfo selectedBookmark = getSelectedBookmark();
hide();
openBookmark(selectedBookmark);
e.consume();
break;
case KeyEvent.VK_ESCAPE:
e.consume();
hide();
returnFocus();
break;
case KeyEvent.VK_DOWN:
e.consume();
selectNext();
break;
case KeyEvent.VK_UP:
e.consume();
selectPrevious();
break;
}
}
}
示例15: getButton
private static int getButton(int direction, int orientation) {
if (direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) {
return (orientation == Adjustable.HORIZONTAL) ? KeyEvent.VK_LEFT : KeyEvent.VK_DOWN;
} else {
return (orientation == Adjustable.HORIZONTAL) ? KeyEvent.VK_RIGHT : KeyEvent.VK_UP;
}
}