本文整理汇总了Java中java.awt.event.KeyEvent.isConsumed方法的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.isConsumed方法的具体用法?Java KeyEvent.isConsumed怎么用?Java KeyEvent.isConsumed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.isConsumed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: postProcessKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public boolean postProcessKeyEvent(KeyEvent ev) {
if (ev.isConsumed())
return false;
if (processShortcut(ev))
return true;
Window w = SwingUtilities.windowForComponent(ev.getComponent());
if (w instanceof Dialog && !WindowManagerImpl.isSeparateWindow(w))
return false;
JFrame mw = (JFrame)WindowManagerImpl.getInstance().getMainWindow();
if (w == mw) {
return false;
}
JMenuBar mb = mw.getJMenuBar();
if (mb == null)
return false;
boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED);
boolean res = invokeProcessKeyBindingsForAllComponents(ev, mw, pressed);
if (res)
ev.consume();
return res;
}
示例3: 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();
}
}
示例4: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public void keyPressed(KeyEvent evt) {
TextRegionManager manager = textRegionManager(evt);
if (manager == null || !manager.isActive() || evt.isConsumed())
return;
KeyStroke evtKeyStroke = KeyStroke.getKeyStrokeForEvent(evt);
if (KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0) == evtKeyStroke) {
manager.escapeAction();
evt.consume();
// } else if (KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) == evtKeyStroke) {
// if (editing.enterAction())
// evt.consume();
//
// } else if (KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0) == evtKeyStroke) {
// if (editing.tabAction())
// evt.consume();
//
// } else if (KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK) == evtKeyStroke) {
// if (editing.shiftTabAction())
// evt.consume();
//
}
}
示例5: processPhaseListenerKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/**
* Lets all registered {@link ProcessEventDecorator}s process the key event for the given
* {@link RenderPhase}. If the event is consumed by any decorator, processing will stop.
*
* @param type
* the type of the key event
* @param e
* the event itself
* @param phase
* the event phase we are in
* @return {@code true} if the event was consumed; {@code false} otherwise
*/
private boolean processPhaseListenerKeyEvent(final KeyEventType type, final KeyEvent e, RenderPhase phase) {
int hoverIndex = model.getHoveringProcessIndex();
ExecutionUnit hoveredProcess = null;
if (hoverIndex >= 0 && hoverIndex < model.getProcesses().size()) {
hoveredProcess = model.getProcess(hoverIndex);
}
for (ProcessEventDecorator decorater : decorators.get(phase)) {
try {
decorater.processKeyEvent(hoveredProcess, type, e);
} catch (RuntimeException e1) {
// catch everything here
LogService.getRoot().log(Level.WARNING,
"com.rapidminer.gui.flow.processrendering.view.ProcessRendererView.decorator_error", e1);
}
// if the decorator consumed the event, it no longer makes sense to use it.
if (e.isConsumed()) {
return true;
}
}
return false;
}
示例6: process
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
protected void process(KeyEvent e) {
// If we've consumed a KeyPressed event,
// then automatically consume any following KeyTyped event
// resulting from the same keypress
// This prevents echoing characters to the Chat area if they're keycommand for selected pieces
if (lastConsumedEvent != null
&& lastConsumedEvent.getWhen() == e.getWhen()) {
e.consume();
}
else {
lastConsumedEvent = null;
}
final int c = e.getKeyCode();
// Don't pass SHIFT or CONTROL only to counters
if (!e.isConsumed() && c != KeyEvent.VK_SHIFT && c != KeyEvent.VK_CONTROL) {
Command comm = KeyBuffer.getBuffer().keyCommand
(KeyStroke.getKeyStrokeForEvent(e));
if (comm != null && !comm.isNull()) {
GameModule.getGameModule().sendAndLog(comm);
e.consume();
lastConsumedEvent = e;
}
}
}
示例7: processKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
protected void processKeyEvent(KeyEvent e) {
fireProcessKeyEvent(e);
if (!e.isConsumed()) {
super.processKeyEvent(e);
}
}
示例8: postProcessKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/**
* This method will be called by {@code dispatchKeyEvent}. It will
* handle any unconsumed KeyEvents that map to an AWT
* {@code MenuShortcut} by consuming the event and activating the
* shortcut.
*
* @param e the KeyEvent to post-process
* @return {@code true}
* @see #dispatchKeyEvent
* @see MenuShortcut
*/
public boolean postProcessKeyEvent(KeyEvent e) {
if (!e.isConsumed()) {
Component target = e.getComponent();
Container p = (Container)
(target instanceof Container ? target : target.getParent());
if (p != null) {
p.postProcessKeyEvent(e);
}
}
return true;
}
示例9: postProcessKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/**
* This method will be called by <code>dispatchKeyEvent</code>. It will
* handle any unconsumed KeyEvents that map to an AWT
* <code>MenuShortcut</code> by consuming the event and activating the
* shortcut.
*
* @param e the KeyEvent to post-process
* @return <code>true</code>
* @see #dispatchKeyEvent
* @see MenuShortcut
*/
public boolean postProcessKeyEvent(KeyEvent e) {
if (!e.isConsumed()) {
Component target = e.getComponent();
Container p = (Container)
(target instanceof Container ? target : target.getParent());
if (p != null) {
p.postProcessKeyEvent(e);
}
}
return true;
}
示例10: dispatchKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public boolean dispatchKeyEvent(KeyEvent e) {
if (skippingEvents || e.isConsumed()) return false;
if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE)
if (SwingUtilities.getRootPane(this) != e.getSource()) { // Closing JPopupMenu using the ESC key
e.consume();
if (DEBUG) System.err.println(">>> Closed by ESC"); // NOI18N
ProfilerPopup.this.hide();
return true;
}
return false;
}
示例11: processKeyBinding
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
boolean ret = super.processKeyBinding(ks, e, condition, pressed);
// XXX #250546 Reason of overriding: to process global shortcut.
if ((JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT == condition) && (ret == false) && !e.isConsumed()) {
Keymap km = Lookup.getDefault().lookup(Keymap.class);
Action action = (km != null) ? km.getAction(ks) : null;
if (action == null) {
return false;
}
if (action instanceof CallbackSystemAction) {
CallbackSystemAction csAction = (CallbackSystemAction) action;
if (tabbedPane != null) {
Action a = tabbedPane.getActionMap().get(csAction.getActionMapKey());
if (a != null) {
a.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks)));
return true;
}
}
}
return false;
} else {
return ret;
}
}
示例12: postProcessKeyEvent
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
public boolean postProcessKeyEvent(KeyEvent ev) {
if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
// mnemonic combination, it's consumed, but we need
// set altKeyPressed to false, otherwise after selection
// component by mnemonic combination a menu will be open
altKeyPressed = false;
return false;
}
if (ev.getKeyCode() == KeyEvent.VK_ALT) {
root = SwingUtilities.getRootPane(ev.getComponent());
winAncestor = (root == null ? null :
SwingUtilities.getWindowAncestor(root));
if (ev.getID() == KeyEvent.KEY_PRESSED) {
if (!altKeyPressed) {
altPressed(ev);
}
altKeyPressed = true;
return true;
} else if (ev.getID() == KeyEvent.KEY_RELEASED) {
if (altKeyPressed) {
altReleased(ev);
} else {
MenuSelectionManager msm =
MenuSelectionManager.defaultManager();
MenuElement[] path = msm.getSelectedPath();
if (path.length <= 0) {
WindowsLookAndFeel.setMnemonicHidden(true);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
}
}
altKeyPressed = false;
}
root = null;
winAncestor = null;
} else {
if (WindowsLookAndFeel.isMnemonicHidden() && ev.isAltDown()) {
WindowsLookAndFeel.setMnemonicHidden(false);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
}
altKeyPressed = false;
}
return false;
}
示例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: processKeyBinding
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
protected @Override boolean processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed) {
if (Utilities.isMac()) {
int mods = e.getModifiers();
boolean isCtrl = (mods & KeyEvent.CTRL_MASK) != 0;
boolean isAlt = (mods & KeyEvent.ALT_MASK) != 0;
if (isAlt && (e instanceof MarkedKeyEvent)) {
mods = mods & ~ KeyEvent.CTRL_MASK;
mods = mods & ~ KeyEvent.CTRL_DOWN_MASK;
mods |= KeyEvent.ALT_MASK;
mods |= KeyEvent.ALT_DOWN_MASK;
KeyEvent newEvent = new MarkedKeyEvent (
(Component) e.getSource(), e.getID(),
e.getWhen(), mods, e.getKeyCode(), e.getKeyChar(),
e.getKeyLocation());
KeyStroke newStroke = null;
if( null != ks ) {
newStroke = e.getID() == KeyEvent.KEY_TYPED ?
KeyStroke.getKeyStroke (ks.getKeyChar(), mods) :
KeyStroke.getKeyStroke (ks.getKeyCode(), mods,
!ks.isOnKeyRelease());
}
boolean result = super.processKeyBinding (newStroke,
newEvent, condition, pressed);
if (newEvent.isConsumed()) {
e.consume();
}
return result;
} else if (!isAlt) {
return super.processKeyBinding (ks, e, condition, pressed);
} else {
return false;
}
} else {
return super.processKeyBinding (ks, e, condition, pressed);
}
}
示例15: keyPressed
import java.awt.event.KeyEvent; //导入方法依赖的package包/类
/****** implementation of KeyListener of fileNameTextField ******/
public void keyPressed(KeyEvent e) {
if (!isVisible()) {
return;
}
int code = e.getKeyCode();
switch (code) {
case KeyEvent.VK_DOWN:
setSelectNext();
e.consume();
break;
case KeyEvent.VK_UP:
setSelectPrevious();
e.consume();
break;
case KeyEvent.VK_ESCAPE:
setVisible(false);
textField.requestFocus();
e.consume();
break;
}
if (isCompletionKey(code, textField) && !e.isConsumed()) {
File file = (File)list.getSelectedValue();
if(file != null) {
if(file.equals(chooser.getCurrentDirectory())) {
chooser.firePropertyChange(JFileChooser.DIRECTORY_CHANGED_PROPERTY, false, true);
} else {
chooser.setSelectedFiles(new File[] {file});
chooser.setCurrentDirectory(file);
}
if (file.isDirectory()) {
try {
Document doc = textField.getDocument();
doc.insertString(doc.getLength(), File.separator, null);
} catch (BadLocationException ex) {
Logger.getLogger(getClass().getName()).log(
Level.FINE, "Cannot append directory separator.", ex);
}
}
}
setVisible(false);
textField.requestFocus();
e.consume();
}
}