本文整理汇总了Java中java.awt.event.KeyEvent.getModifiersEx方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.getModifiersEx方法的具体用法?Java KeyEvent.getModifiersEx怎么用?Java KeyEvent.getModifiersEx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.getModifiersEx方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attemptReface
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
private void attemptReface(Canvas canvas, final Direction facing, KeyEvent e) {
if (e.getModifiersEx() == 0) {
final Circuit circuit = canvas.getCircuit();
final Selection sel = canvas.getSelection();
SetAttributeAction act = new SetAttributeAction(circuit, Strings.getter("selectionRefaceAction"));
for (Component comp : sel.getComponents()) {
if (!(comp instanceof Wire)) {
Attribute<Direction> attr = getFacingAttribute(comp);
if (attr != null) {
act.set(comp, attr, facing);
}
}
}
if (!act.isEmpty()) {
canvas.getProject().doAction(act);
e.consume();
}
}
}
示例2: keyTyped
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
int ign = InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.META_DOWN_MASK;
if ((e.getModifiersEx() & ign) != 0)
return;
char c = e.getKeyChar();
if (c == '\n') {
stopEditing();
} else if (c != KeyEvent.CHAR_UNDEFINED && !Character.isISOControl(c)) {
if (pos < curText.length()) {
curText = curText.substring(0, pos) + c + curText.substring(pos);
} else {
curText += c;
}
++pos;
field.setText(curText);
}
}
示例3: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
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);
}
示例4: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
return;
}
modifiersEx = e.getModifiersEx();
exText = InputEvent.getModifiersExText(modifiersEx);
keyPressedFlag = true;
synchronized (lock) {
lock.notifyAll();
}
}
示例5: keyTyped
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
int mask = e.getModifiersEx();
if ((mask & ~InputEvent.SHIFT_DOWN_MASK) != 0)
return;
char c = e.getKeyChar();
int cols = hex.getMeasures().getColumnCount();
switch (c) {
case ' ':
if (cursor >= 0)
setDot(cursor + 1, (mask & InputEvent.SHIFT_DOWN_MASK) != 0);
break;
case '\n':
if (cursor >= 0)
setDot(cursor + cols, (mask & InputEvent.SHIFT_DOWN_MASK) != 0);
break;
case '\u0008':
case '\u007f':
hex.delete();
// setDot(cursor - 1, (mask & InputEvent.SHIFT_MASK) != 0);
break;
default:
int digit = Character.digit(e.getKeyChar(), 16);
if (digit >= 0) {
HexModel model = hex.getModel();
if (model != null && cursor >= model.getFirstOffset() && cursor <= model.getLastOffset()) {
int curValue = model.get(cursor);
int newValue = 16 * curValue + digit;
model.set(cursor, newValue);
}
}
}
}
示例6: keyEventReceived
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public KeyConfigurationResult keyEventReceived(KeyConfigurationEvent event) {
if (event.getType() == KeyConfigurationEvent.KEY_PRESSED) {
KeyEvent e = event.getKeyEvent();
if (e.getModifiersEx() == modsEx) {
Direction value = null;
switch (e.getKeyCode()) {
case KeyEvent.VK_UP:
value = Direction.NORTH;
break;
case KeyEvent.VK_DOWN:
value = Direction.SOUTH;
break;
case KeyEvent.VK_LEFT:
value = Direction.WEST;
break;
case KeyEvent.VK_RIGHT:
value = Direction.EAST;
break;
}
if (value != null) {
event.consume();
return new KeyConfigurationResult(event, attr, value);
}
}
}
return null;
}
示例7: keyEventReceived
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public KeyConfigurationResult keyEventReceived(KeyConfigurationEvent event) {
if (event.getType() == KeyConfigurationEvent.KEY_TYPED) {
KeyEvent e = event.getKeyEvent();
int digit = Character.digit(e.getKeyChar(), radix);
if (digit >= 0 && e.getModifiersEx() == modsEx) {
long now = System.currentTimeMillis();
long sinceLast = now - whenTyped;
AttributeSet attrs = event.getAttributeSet();
int min = getMinimumValue(attrs);
int max = getMaximumValue(attrs);
int val = 0;
if (sinceLast < MAX_TIME_KEY_LASTS) {
val = radix * curValue;
if (val > max) {
val = 0;
}
}
val += digit;
if (val > max) {
val = digit;
if (val > max) {
return null;
}
}
event.consume();
whenTyped = now;
curValue = val;
if (val >= min) {
Object valObj = createValue(val);
return new KeyConfigurationResult(event, attr, valObj);
}
}
}
return null;
}
示例8: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@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();
}
}
示例9: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@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());
}
}
}
示例10: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(final KeyEvent e) {
modifiersEX = e.getModifiersEx();
modifiers = e.getModifiers();
}
示例11: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@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;
}
}
示例12: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@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;
}
}
示例13: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(Canvas canvas, KeyEvent event) {
processKeyEvent(canvas, event, KeyConfigurationEvent.KEY_PRESSED);
if (!event.isConsumed() && event.getModifiersEx() == 0) {
switch (event.getKeyCode()) {
case KeyEvent.VK_UP:
setFacing(canvas, Direction.NORTH);
break;
case KeyEvent.VK_DOWN:
setFacing(canvas, Direction.SOUTH);
break;
case KeyEvent.VK_LEFT:
setFacing(canvas, Direction.WEST);
break;
case KeyEvent.VK_RIGHT:
setFacing(canvas, Direction.EAST);
break;
case KeyEvent.VK_BACK_SPACE:
if (lastAddition != null && canvas.getProject().getLastAction() == lastAddition) {
canvas.getProject().undoAction();
lastAddition = null;
}
break;
case KeyEvent.VK_DELETE:
case KeyEvent.VK_ESCAPE:
if (state == SHOW_GHOST) {
Project proj = canvas.getProject();
Tool next = determineNext(proj);
if (next != null) {
proj.setTool(next);
Action act = SelectionActions.dropAll(canvas.getSelection());
if (act != null) {
proj.doAction(act);
}
}
}
break;
}
}
}
示例14: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@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
}
}