java.awt.event.KeyListener.keyReleased()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(251)

本文整理了Java中java.awt.event.KeyListener.keyReleased()方法的一些代码示例,展示了KeyListener.keyReleased()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyListener.keyReleased()方法的具体详情如下:
包路径:java.awt.event.KeyListener
类名称:KeyListener
方法名:keyReleased

KeyListener.keyReleased介绍

[英]Invoked when a key has been released. See the class description for KeyEvent for a definition of a key released event.
[中]在释放密钥时调用。有关密钥释放事件的定义,请参见KeyEvent的类描述。

代码示例

代码示例来源:origin: net.sf.nachocalendar/nachocalendar

/**
 * Notifies all registered listeners about the event.
 *
 * @param event The event to be fired
 */
private void fireKeyListenerKeyReleased(final java.awt.event.KeyEvent event) {
  if (listenerList == null) {
    return;
  }
  final Object[] listeners = listenerList.getListenerList();
  for (int i = listeners.length - 2; i >= 0; i -= 2) {
    if (listeners[i] == java.awt.event.KeyListener.class) {
      ((java.awt.event.KeyListener) listeners[i + 1]).keyReleased(event);
    }
  }
}

代码示例来源:origin: net.sf.nachocalendar/nachocalendar

/**
 * Notifies all registered listeners about the event.
 * 
 * @param event
 *            The event to be fired
 */
private void fireKeyListenerKeyReleased(final java.awt.event.KeyEvent event) {
  if (listenerList == null) {
    return;
  }
  final Object[] listeners = listenerList.getListenerList();
  for (int i = listeners.length - 2; i >= 0; i -= 2) {
    if (listeners[i] == java.awt.event.KeyListener.class) {
      ((java.awt.event.KeyListener) listeners[i + 1]).keyReleased(event);
    }
  }
}

代码示例来源:origin: sc.fiji/fiji-lib

@Override
public final void keyReleased(KeyEvent e) {
  if (isThisTool())
    listener.keyReleased(e);
}

代码示例来源:origin: com.synaptix/SynaptixSwing

public void keyReleased(KeyEvent e) {
    for(KeyListener kl : JDateHourField.this.getKeyListeners())
      kl.keyReleased(e);
  }
}

代码示例来源:origin: sc.fiji/Simple_Neurite_Tracer

@Override
public void keyReleased(final KeyEvent e) {
  for (final KeyListener kl : listeners) {
    if (e.isConsumed())
      break;
    kl.keyReleased(e);
  }
}

代码示例来源:origin: gurkenlabs/litiengine

/**
 * Execute released keys.
 */
private void executeReleasedKeys() {
 this.releasedKeys.forEach(key -> {
  this.keySpecificReleasedConsumer.forEach(consumer -> {
   if (consumer.getKey().intValue() == key.getKeyCode()) {
    consumer.getValue().accept(key);
   }
  });
  this.keyReleasedConsumer.forEach(consumer -> consumer.accept(key));
  this.keyListeners.forEach(listener -> listener.keyReleased(key));
 });
 this.releasedKeys.clear();
}

代码示例来源:origin: com.googlecode.gstreamer-java/gstreamer-java

@Override
  public void keyReleased(KeyEvent evt) {
    for (KeyListener l : videoComponent.getKeyListeners()) {
      l.keyReleased(evt);
    }
  }
});

代码示例来源:origin: xyz.cofe/docking-frames-core

public boolean keyReleased( DockElement element, KeyEvent event ){
  if( element == AbstractDockable.this ){
    for( KeyListener listener : getKeyListeners() ){
      listener.keyReleased( event );
    }
    return event.isConsumed();
  }
  else{
    return false;
  }
}

代码示例来源:origin: sc.fiji/fiji-lib

@Override
public final void keyReleased(KeyEvent e) {
  if (!e.isConsumed())
    listener.keyReleased(e);
}

代码示例来源:origin: org.gdl-lang.gdl-tools/openehr-utils-gui-swing

public void actionPerformed(ActionEvent ev) {
    getJTextField().setText("");
    if (_keyListener != null) {
      _keyListener.keyReleased(null);
    }
  }
});

代码示例来源:origin: brackeen/Scared

public void keyReleased(KeyEvent e) {
  KeyListener keyListener = getFocusedViewKeyListener();
  if (keyListener != null) {
    keyListener.keyReleased(e);
  }
}

代码示例来源:origin: jzy3d/jzy3d-api

@Override
public void keyReleased(KeyEvent ke) {
  keyListener.keyReleased(convertEvent(ke, java.awt.event.KeyEvent.KEY_RELEASED));
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
  public void keyReleased(KeyEvent e) {
    KeyListener[] kls = getKeyListeners();
    if (kls != null) {
      e.setSource(ModelComponentDecorator.this);
      for (KeyListener kl : kls) {
        kl.keyReleased(e);
      }
    }
  }
});

代码示例来源:origin: freeplane/freeplane

@Override
  protected void processKeyEvent(final KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      final EventListener[] el = super.getListeners(KeyListener.class);
      if (e.getID() != KeyEvent.KEY_RELEASED) {
        return;
      }
      for (int i = 0; i < el.length; i++) {
        final KeyListener kl = (KeyListener) el[i];
        kl.keyReleased(e);
      }
      return;
    }
    super.processKeyEvent(e);
  }
}

代码示例来源:origin: com.threerings/nenya

public void windowLostFocus (WindowEvent e)
{
  // un-press any keys that were left down
  if (!_downKeys.isEmpty()) {
    long now = System.currentTimeMillis();
    for (KeyEvent down : _downKeys.values()) {
      KeyEvent up = new KeyEvent(
        down.getComponent(), KeyEvent.KEY_RELEASED, now,
        down.getModifiers(), down.getKeyCode(), down.getKeyChar(),
        down.getKeyLocation());
      for (int ii = 0, nn = _listeners.size(); ii < nn; ii++) {
        _listeners.get(ii).keyReleased(up);
      }
    }
    _downKeys.clear();
  }
}

代码示例来源:origin: threerings/nenya

public void windowLostFocus (WindowEvent e)
{
  // un-press any keys that were left down
  if (!_downKeys.isEmpty()) {
    long now = System.currentTimeMillis();
    for (KeyEvent down : _downKeys.values()) {
      KeyEvent up = new KeyEvent(
        down.getComponent(), KeyEvent.KEY_RELEASED, now,
        down.getModifiers(), down.getKeyCode(), down.getKeyChar(),
        down.getKeyLocation());
      for (int ii = 0, nn = _listeners.size(); ii < nn; ii++) {
        _listeners.get(ii).keyReleased(up);
      }
    }
    _downKeys.clear();
  }
}

代码示例来源:origin: triplea-game/triplea

@Test
public void testKeyReleaseListener() {
 final KeyEvent event = mock(KeyEvent.class);
 final KeyListener action = SwingAction.keyReleaseListener(consumer);
 action.keyReleased(event);
 verify(consumer).accept(event);
}

代码示例来源:origin: sdedit/sdedit

/**
 * Redoes the last action, if any has been performed.
 */
public void redo() {
  try {
    if (undoManager.canRedo()) {
      undoManager.redo();
      for (KeyListener kl : getKeyListeners()) {
        kl.keyTyped(null);
        kl.keyReleased(null);
      }
    }
  } catch (CannotRedoException e) {
  }
}

代码示例来源:origin: sdedit/sdedit

/**
 * Undoes the last action, if any has been performed.
 */
public void undo() {
  try {
    if (undoManager.canUndo()) {
      undoManager.undo();
      for (KeyListener kl : getKeyListeners()) {
        kl.keyTyped(null);
        kl.keyReleased(null);
      }
    }
  } catch (CannotUndoException e) {
  }
}

代码示例来源:origin: UISpec4J/UISpec4J

private static void dispatchEvent(int eventCode, Key key, int keyCode, Component component) {
 int modifier = key.getModifier().getCode();
 KeyEvent event = new KeyEvent(component, eventCode, 0, modifier, keyCode, key.getChar());
 for (KeyListener listener : component.getKeyListeners()) {
  switch (eventCode) {
   case KEY_PRESSED:
    listener.keyPressed(event);
    break;
   case KEY_TYPED:
    listener.keyTyped(event);
    break;
   case KEY_RELEASED:
    listener.keyReleased(event);
    break;
  }
 }
 SwingUtilities.processKeyBindings(event);
}

相关文章