本文整理汇总了Java中java.awt.event.KeyEvent.VK_END属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_END属性的具体用法?Java KeyEvent.VK_END怎么用?Java KeyEvent.VK_END使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_END属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleSpecialKey
public void handleSpecialKey(KeyEvent ke) {
if(ke.getKeyCode() == KeyEvent.VK_END) {
insertToCode.moveToEndOfCurrentLine();
} else if(ke.getKeyCode() == KeyEvent.VK_HOME) {
insertToCode.moveToStartOfCurrentLine();
}
}
示例2: getKeys
@Override
public NavigationKey[] getKeys(ComponentOperator oper) {
boolean multiString
= oper instanceof JTextAreaOperator
|| oper instanceof JEditorPaneOperator;
NavigationKey[] result = new NavigationKey[multiString ? 8 : 4];
result[0] = new UpKey(KeyEvent.VK_LEFT, 0);
result[1] = new DownKey(KeyEvent.VK_RIGHT, 0);
((UpKey) result[0]).setDownKey((DownKey) result[1]);
((DownKey) result[1]).setUpKey((UpKey) result[0]);
if (multiString) {
result[2] = new UpKey(KeyEvent.VK_UP, 0);
result[3] = new DownKey(KeyEvent.VK_DOWN, 0);
((UpKey) result[2]).setDownKey((DownKey) result[3]);
((DownKey) result[3]).setUpKey((UpKey) result[2]);
result[4] = new UpKey(KeyEvent.VK_PAGE_UP, 0);
result[5] = new DownKey(KeyEvent.VK_PAGE_DOWN, 0);
((UpKey) result[4]).setDownKey((DownKey) result[5]);
((DownKey) result[5]).setUpKey((UpKey) result[4]);
result[6] = new HomeKey(KeyEvent.VK_HOME, InputEvent.CTRL_MASK);
result[7] = new EndKey(KeyEvent.VK_END, InputEvent.CTRL_MASK, this, oper);
} else {
result[2] = new HomeKey(KeyEvent.VK_HOME, 0);
result[3] = new EndKey(KeyEvent.VK_END, 0, this, oper);
}
return result;
}
示例3: keyPressed
@Override
public void keyPressed(InstanceState state, KeyEvent e) {
KeyboardData data = getKeyboardState(state);
boolean changed = false;
boolean used = true;
synchronized (data) {
switch (e.getKeyCode()) {
case KeyEvent.VK_DELETE:
changed = data.delete();
break;
case KeyEvent.VK_LEFT:
data.moveCursorBy(-1);
break;
case KeyEvent.VK_RIGHT:
data.moveCursorBy(1);
break;
case KeyEvent.VK_HOME:
data.setCursor(0);
break;
case KeyEvent.VK_END:
data.setCursor(Integer.MAX_VALUE);
break;
default:
used = false;
}
}
if (used)
e.consume();
if (changed)
state.getInstance().fireInvalidated();
}
示例4: keyPressed
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
arrowKeySelect(DIRECTION_UP);
break;
case KeyEvent.VK_DOWN:
arrowKeySelect(DIRECTION_DOWN);
break;
case KeyEvent.VK_ENTER:
doubleClickEventDispatch();
break;
case KeyEvent.VK_PAGE_DOWN:
pageScrollViewport(DIRECTION_DOWN);
break;
case KeyEvent.VK_PAGE_UP:
pageScrollViewport(DIRECTION_UP);
break;
case KeyEvent.VK_HOME:
((ScrollPane)callback.getPane()).setScrollPosition(((ScrollPane)callback.getPane()).getScrollPosition().x, 0);
break;
case KeyEvent.VK_END:
((ScrollPane)callback.getPane()).setScrollPosition(((ScrollPane)callback.getPane()).getScrollPosition().x,
callback.getSize().height);
break;
default:
;
}
callback.repaint();
}
示例5: keyPressed
@Override
public void keyPressed(KeyEvent e) {
int code = e.getKeyCode();
boolean consumeEvent = true;
switch (code) {
case KeyEvent.VK_ENTER:
case KeyEvent.VK_SPACE:
// selection confirmed
releaseUI(true);
break;
case KeyEvent.VK_ESCAPE:
// action canceled
releaseUI(false);
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_DOWN:
case KeyEvent.VK_TAB:
selectedIndex++;
if (selectedIndex == segments.length) {
selectedIndex = 0;
}
requestRepaint();
break;
case KeyEvent.VK_LEFT:
case KeyEvent.VK_UP:
selectedIndex--;
if (selectedIndex < 0) {
selectedIndex = segments.length - 1;
}
requestRepaint();
break;
case KeyEvent.VK_HOME:
selectedIndex = 0;
requestRepaint();
break;
case KeyEvent.VK_END:
selectedIndex = segments.length - 1;
requestRepaint();
break;
default:
int mods = e.getModifiersEx();
for (int x = 0; x < stopEvents.length; x++) {
if (stopEvents[x].getKeyCode() == code &&
(stopEvents[x].getModifiers() & mods) == stopEvents[x].getModifiers()) {
releaseUI(false);
consumeEvent = false;
break;
}
}
for (int x = 0; x < confirmEvents.length; x++) {
if (confirmEvents[x].getKeyCode() == code &&
(confirmEvents[x].getModifiers() & mods) == confirmEvents[x].getModifiers()) {
releaseUI(true);
break;
}
}
}
if (consumeEvent) {
e.consume();
}
}
示例6: keyPressed
@Override
public void keyPressed(KeyEvent e) {
if (this.pane == null) {
if (e.getSource() instanceof ItemPanel) {
this.pane = ((ItemPanel) e.getSource());
} else if (e.getSource() instanceof Item) {
this.pane = ((ItemPanel) ((JComponent) e.getSource()).getParent());
}
}
if (e.getKeyCode() == KeyEvent.VK_DELETE) {
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
if ((this.pane != null) && (this.pane.getFilePane().lastSelected != null)) {
this.pane.getFilePane().filechooserUI.setCurrentDirectoryOfFileChooser(this.pane.getFilePane().lastSelected
.getFile());
}
} else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
this.pane.useKeyMoves("SPACE", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
this.pane.useKeyMoves("RIGHT", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
this.pane.useKeyMoves("LEFT", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_UP) {
this.pane.useKeyMoves("UP", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
this.pane.useKeyMoves("DOWN", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_HOME) {
this.pane.useKeyMoves("HOME", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_END) {
this.pane.useKeyMoves("END", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
// ignore enter here!
} else if (e.getKeyCode() == KeyEvent.VK_PAGE_UP) {
this.pane.useKeyMoves("PAGE_UP", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else if (e.getKeyCode() == KeyEvent.VK_PAGE_DOWN) {
this.pane.useKeyMoves("PAGE_DOWN", e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK);
} else {
if (KeyEvent.getKeyText(e.getKeyCode()).toLowerCase().equals("a")
&& (e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK)) {
this.pane.getFilePane().selectAll();
}
if (e.getModifiersEx() == 0) {
this.pane.forwardToNearestFor(String.valueOf(e.getKeyChar()).toLowerCase());
}
}
}
示例7: keyEventGetKeyText
public static String keyEventGetKeyText(int keycode) {
if (keycode == KeyEvent.VK_TAB) {
return "Tab";
}
if (keycode == KeyEvent.VK_CONTROL) {
return "Ctrl";
}
if (keycode == KeyEvent.VK_ALT) {
return "Alt";
}
if (keycode == KeyEvent.VK_SHIFT) {
return "Shift";
}
if (keycode == KeyEvent.VK_META) {
return "Meta";
}
if (keycode == KeyEvent.VK_SPACE) {
return "Space";
}
if (keycode == KeyEvent.VK_BACK_SPACE) {
return "Backspace";
}
if (keycode == KeyEvent.VK_HOME) {
return "Home";
}
if (keycode == KeyEvent.VK_END) {
return "End";
}
if (keycode == KeyEvent.VK_DELETE) {
return "Delete";
}
if (keycode == KeyEvent.VK_PAGE_UP) {
return "Pageup";
}
if (keycode == KeyEvent.VK_PAGE_DOWN) {
return "Pagedown";
}
if (keycode == KeyEvent.VK_UP) {
return "Up";
}
if (keycode == KeyEvent.VK_DOWN) {
return "Down";
}
if (keycode == KeyEvent.VK_LEFT) {
return "Left";
}
if (keycode == KeyEvent.VK_RIGHT) {
return "Right";
}
if (keycode == KeyEvent.VK_ENTER) {
return "Enter";
}
return KeyEvent.getKeyText(keycode);
}
示例8: keyPressed
@Override
public void keyPressed(KeyEvent e) {
int cols = hex.getMeasures().getColumnCount();
int rows;
boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
if (cursor >= cols)
setDot(cursor - cols, shift);
break;
case KeyEvent.VK_LEFT:
if (cursor >= 1)
setDot(cursor - 1, shift);
break;
case KeyEvent.VK_DOWN:
if (cursor >= hex.getModel().getFirstOffset() && cursor <= hex.getModel().getLastOffset() - cols) {
setDot(cursor + cols, shift);
}
break;
case KeyEvent.VK_RIGHT:
if (cursor >= hex.getModel().getFirstOffset() && cursor <= hex.getModel().getLastOffset() - 1) {
setDot(cursor + 1, shift);
}
break;
case KeyEvent.VK_HOME:
if (cursor >= 0) {
int dist = (int) (cursor % cols);
if (dist == 0)
setDot(0, shift);
else
setDot(cursor - dist, shift);
break;
}
case KeyEvent.VK_END:
if (cursor >= 0) {
HexModel model = hex.getModel();
long dest = (cursor / cols * cols) + cols - 1;
if (model != null) {
long end = model.getLastOffset();
if (dest > end || dest == cursor)
dest = end;
setDot(dest, shift);
} else {
setDot(dest, shift);
}
}
break;
case KeyEvent.VK_PAGE_DOWN:
rows = hex.getVisibleRect().height / hex.getMeasures().getCellHeight();
if (rows > 2)
rows--;
if (cursor >= 0) {
long max = hex.getModel().getLastOffset();
if (cursor + rows * cols <= max) {
setDot(cursor + rows * cols, shift);
} else {
long n = cursor;
while (n + cols < max)
n += cols;
setDot(n, shift);
}
}
break;
case KeyEvent.VK_PAGE_UP:
rows = hex.getVisibleRect().height / hex.getMeasures().getCellHeight();
if (rows > 2)
rows--;
if (cursor >= rows * cols)
setDot(cursor - rows * cols, shift);
else if (cursor >= cols)
setDot(cursor % cols, shift);
break;
}
}
示例9: keyPressed
@Override
public void keyPressed(KeyEvent e) {
if (cursorRow < 0)
return;
TruthTable model = table.getTruthTable();
int rows = model.getRowCount();
int inputs = model.getInputColumnCount();
int outputs = model.getOutputColumnCount();
int cols = inputs + outputs;
boolean shift = (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0;
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
setCursor(cursorRow - 1, cursorCol, shift);
break;
case KeyEvent.VK_LEFT:
setCursor(cursorRow, cursorCol - 1, shift);
break;
case KeyEvent.VK_DOWN:
setCursor(cursorRow + 1, cursorCol, shift);
break;
case KeyEvent.VK_RIGHT:
setCursor(cursorRow, cursorCol + 1, shift);
break;
case KeyEvent.VK_HOME:
if (cursorCol == 0)
setCursor(0, 0, shift);
else
setCursor(cursorRow, 0, shift);
break;
case KeyEvent.VK_END:
if (cursorCol == cols - 1)
setCursor(rows - 1, cols - 1, shift);
else
setCursor(cursorRow, cols - 1, shift);
break;
case KeyEvent.VK_PAGE_DOWN:
rows = table.getVisibleRect().height / table.getCellHeight();
if (rows > 2)
rows--;
setCursor(cursorRow + rows, cursorCol, shift);
break;
case KeyEvent.VK_PAGE_UP:
rows = table.getVisibleRect().height / table.getCellHeight();
if (rows > 2)
rows--;
setCursor(cursorRow - rows, cursorCol, shift);
break;
}
}
示例10: keyPressed
@Override
public void keyPressed(KeyEvent e) {
int ign = InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK;
if ((e.getModifiersEx() & ign) != 0)
return;
switch (e.getKeyCode()) {
case KeyEvent.VK_LEFT:
case KeyEvent.VK_KP_LEFT:
if (pos > 0)
--pos;
break;
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_KP_RIGHT:
if (pos < curText.length())
++pos;
break;
case KeyEvent.VK_HOME:
pos = 0;
break;
case KeyEvent.VK_END:
pos = curText.length();
break;
case KeyEvent.VK_ESCAPE:
case KeyEvent.VK_CANCEL:
cancelEditing();
break;
case KeyEvent.VK_CLEAR:
curText = "";
pos = 0;
break;
case KeyEvent.VK_ENTER:
stopEditing();
break;
case KeyEvent.VK_BACK_SPACE:
if (pos > 0) {
curText = curText.substring(0, pos - 1) + curText.substring(pos);
--pos;
field.setText(curText);
}
break;
case KeyEvent.VK_DELETE:
if (pos < curText.length()) {
curText = curText.substring(0, pos) + curText.substring(pos + 1);
field.setText(curText);
}
break;
case KeyEvent.VK_INSERT:
case KeyEvent.VK_COPY:
case KeyEvent.VK_CUT:
case KeyEvent.VK_PASTE:
// TODO: enhance label editing
break;
default:
; // ignore
}
}