本文整理汇总了Java中java.awt.event.KeyEvent.consume方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.consume方法的具体用法?Java KeyEvent.consume怎么用?Java KeyEvent.consume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.consume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(Canvas canvas, KeyEvent e) {
if (state == MOVING && e.getKeyCode() == KeyEvent.VK_SHIFT) {
handleMoveDrag(canvas, curDx, curDy, e.getModifiersEx());
} else {
switch (e.getKeyCode()) {
case KeyEvent.VK_BACK_SPACE:
case KeyEvent.VK_DELETE:
if (!canvas.getSelection().isEmpty()) {
Action act = SelectionActions.clear(canvas.getSelection());
canvas.getProject().doAction(act);
e.consume();
}
break;
default:
processKeyEvent(canvas, e, KeyConfigurationEvent.KEY_PRESSED);
}
}
}
示例2: processKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
protected void processKeyEvent(KeyEvent e) {
KeyStroke ks = KeyStroke.getKeyStrokeForEvent(e);
if (enter.equals(ks)) {
// Prevent JComponent.processKeyBindings() to be called (it is called from
// JComponent.processKeyEvent() ), notify only registered key listeners
int id = e.getID();
for (KeyListener keyListener : getKeyListeners()) {
switch(id) {
case KeyEvent.KEY_TYPED:
keyListener.keyTyped(e);
break;
case KeyEvent.KEY_PRESSED:
keyListener.keyPressed(e);
break;
case KeyEvent.KEY_RELEASED:
keyListener.keyReleased(e);
break;
}
}
if (!e.isConsumed() && id == KeyEvent.KEY_PRESSED) {
synchronized(listeners) {
List<CellEditorListener> list = new ArrayList<CellEditorListener>(listeners);
for (CellEditorListener listener : list) {
listener.editingStopped(new ChangeEvent(this));
}
}
}
e.consume();
} else {
super.processKeyEvent(e);
}
}
示例3: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == ' ') {
JTree tree = (JTree) e.getSource();
TreePath path = tree.getSelectionPath();
if( null == path )
return;
Node node = Visualizer.findNode( path.getLastPathComponent() );
if( null == node )
return;
boolean isSelected = settings.isNodeVisible( node );
settings.setNodeVisible( node, !isSelected );
tree.repaint();
e.consume();
}
}
示例4: keyTyped
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyTyped(KeyEvent k) {
if (k.getKeyChar() == '\n' && k.isControlDown()) {
k.consume();
executeCurrentSQL();
}
}
示例5: keyReleased
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyReleased(KeyEvent ke) {
if(letTextPaneHandleKey(ke)) {
return;
} else if(sc) {
sc = false;
} else if(ke.getKeyCode() == KeyEvent.VK_DELETE) {
codeInputHandler.delete();
} else {
codeInputHandler.handleSpecialKey(ke);
}
ke.consume();
}
示例6: keyReleased
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/**
* the key released event
* @param event
*/
@Override
public void keyReleased(KeyEvent event)
{
if(event.getModifiers() != SHORTCUT_MASK && !(isDeadKey(event) && isActive) )
{
event.consume();
}
}
示例7: keyTyped
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyTyped(KeyEvent e) {
key = e.getKeyChar();
if (key == (char) 127 || key == '\b' || key == '\n') {
e.consume();
return;
}
if (e.getModifiers() == KeyEvent.CTRL_MASK) {
return;
}
palavra = insertChar(palavra, key);
posCursor++;
}
示例8: processKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void processKeyEvent(KeyEvent ke) {
//override the default handling so that
//the parent will never receive the escape key and
//close a modal dialog
if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
removeSearchField();
ke.consume();
} else {
super.processKeyEvent(ke);
}
}
示例9: keyReleased
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyReleased(KeyEvent event) {
super.keyPressed(event);
if (!event.isConsumed() && event.getSource() == criteria.getSearchTextField() && event.getKeyChar() == KeyEvent.VK_ENTER) {
event.consume();
refreshData();
}
}
示例10: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent evt) {
if (evt.getModifiers() == 0 && evt.getKeyCode() == KeyEvent.VK_ENTER) {
evt.consume();
btnSignIn.doClick();
}
}
示例11: altPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
void altPressed(KeyEvent ev) {
MenuSelectionManager msm =
MenuSelectionManager.defaultManager();
MenuElement[] path = msm.getSelectedPath();
if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
msm.clearSelectedPath();
menuCanceledOnPress = true;
ev.consume();
} else if(path.length > 0) { // We are in ComboBox
menuCanceledOnPress = false;
WindowsLookAndFeel.setMnemonicHidden(false);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
ev.consume();
} else {
menuCanceledOnPress = false;
WindowsLookAndFeel.setMnemonicHidden(false);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
JMenuBar mbar = root != null ? root.getJMenuBar() : null;
if(mbar == null && winAncestor instanceof JFrame) {
mbar = ((JFrame)winAncestor).getJMenuBar();
}
JMenu menu = mbar != null ? mbar.getMenu(0) : null;
if(menu != null) {
ev.consume();
}
}
}
示例12: processKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
protected void processKeyEvent(KeyEvent event) {
if (event.getID() == KeyEvent.KEY_RELEASED) {
int row = getSelectedRow();
if (row != -1) {
if (event.getKeyCode() == KeyEvent.VK_LEFT) {
if (treeRenderer.isExpanded(row)) {
treeRenderer.collapseRow(row);
} else {
int parentRow = treeRenderer.getRowForPath(treeRenderer.getPathForRow(row).getParentPath());
treeRenderer.collapseRow(parentRow);
getSelectionModel().setSelectionInterval(parentRow, parentRow);
}
event.consume();
return;
}
if (event.getKeyCode() == KeyEvent.VK_RIGHT) {
if (treeRenderer.isCollapsed(row)) {
treeRenderer.expandRow(row);
}
event.consume();
return;
}
}
}
super.processKeyEvent(event);
}
示例13: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_ESCAPE) {
removeSearchField();
ETable.this.requestFocus();
} else if (keyCode == KeyEvent.VK_UP) {
currentSelectionIndex--;
displaySearchResult();
// Stop processing the event here. Otherwise it's dispatched
// to the table too (which scrolls)
e.consume();
} else if (keyCode == KeyEvent.VK_DOWN) {
currentSelectionIndex++;
displaySearchResult();
// Stop processing the event here. Otherwise it's dispatched
// to the table too (which scrolls)
e.consume();
} else if (keyCode == KeyEvent.VK_TAB) {
if (maxPrefix != null) {
searchTextField.setText(maxPrefix);
}
e.consume();
} else if (keyCode == KeyEvent.VK_ENTER) {
removeSearchField();
// TODO: do something on hitting enter???
e.consume();
ETable.this.requestFocus();
}
}
示例14: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == ' ') {
JTree tree = (JTree) e.getSource();
TreePath path = tree.getSelectionPath();
if (path != null) {
CheckNode node = (CheckNode) path.getLastPathComponent();
node.setSelected(!node.isSelected());
tree.repaint();
e.consume();
}
}
}
示例15: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_SPACE) {
JTree tree = (JTree) e.getSource();
TreePath path = tree.getSelectionPath();
if (path != null) {
FileNode node = (FileNode) path.getLastPathComponent();
node.setSelected(!node.isSelected());
tree.repaint();
e.consume();
}
}
}