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

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

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

KeyListener.keyTyped介绍

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

代码示例

代码示例来源:origin: net.imagej/ij

public void keyTyped (KeyEvent e) {
  if (keyListener!=null)
    keyListener.keyTyped(e);
}

代码示例来源:origin: imagej/ImageJA

public void keyTyped (KeyEvent e) {
  if (keyListener!=null)
    keyListener.keyTyped(e);
}

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

/**
 * Notifies all registered listeners about the event.
 *
 * @param event The event to be fired
 */
private void fireKeyListenerKeyTyped(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]).keyTyped(event);
    }
  }
}

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

/**
 * Notifies all registered listeners about the event.
 * 
 * @param event
 *            The event to be fired
 */
private void fireKeyListenerKeyTyped(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]).keyTyped(event);
    }
  }
}

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

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

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

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

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

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

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

/**
 * Execute typed keys.
 */
private void executeTypedKeys() {
 this.typedKeys.forEach(key -> {
  this.keySpecificTypedConsumer.forEach(consumer -> {
   if (consumer.getKey().intValue() == key.getKeyCode()) {
    consumer.getValue().accept(key);
   }
  });
  this.keyTypedConsumer.forEach(consumer -> consumer.accept(key));
  this.keyListeners.forEach(listener -> listener.keyTyped(key));
 });
 this.typedKeys.clear();
}

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

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

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

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

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

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

代码示例来源:origin: JetBrains/jediterm

public void handleKeyEvent(@NotNull KeyEvent e) {
 final int id = e.getID();
 if (id == KeyEvent.KEY_PRESSED) {
  for (KeyListener keyListener : myCustomKeyListeners) {
   keyListener.keyPressed(e);
  }
 } else if (id == KeyEvent.KEY_TYPED) {
  for (KeyListener keyListener : myCustomKeyListeners) {
   keyListener.keyTyped(e);
  }
 }
}

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

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

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

public void eventDispatched(AWTEvent aWTEvent) {
    if (aWTEvent instanceof KeyEvent) {
      KeyEvent evt = (KeyEvent)aWTEvent;
      for (KeyListener kl : getKeyListeners()) {
        int id = aWTEvent.getID();
        switch (id) {
          case KeyEvent.KEY_PRESSED:
            kl.keyPressed(evt);
            break;
          case KeyEvent.KEY_RELEASED:
            kl.keyReleased(evt);
            break;
          case KeyEvent.KEY_TYPED:
            kl.keyTyped(evt);
            break;
          default:
            System.err.println("Unhandled Key ID: " + id);    
        }
      }
    }
  }
};

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
  public void eventDispatched(AWTEvent aWTEvent) {
    if (aWTEvent instanceof KeyEvent) {
      KeyEvent evt = (KeyEvent)aWTEvent;
      for (KeyListener kl : getKeyListeners()) {
        int id = aWTEvent.getID();
        switch (id) {
          case KeyEvent.KEY_PRESSED:
            kl.keyPressed(evt);
            break;
          case KeyEvent.KEY_RELEASED:
            kl.keyReleased(evt);
            break;
          case KeyEvent.KEY_TYPED:
            kl.keyTyped(evt);
            break;
          default:
            System.err.println("Unhandled Key ID: " + id);    
        }
      }
    }
  }
};

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
  public void eventDispatched(AWTEvent aWTEvent) {
    if (aWTEvent instanceof KeyEvent) {
      KeyEvent evt = (KeyEvent)aWTEvent;
      for (KeyListener kl : getKeyListeners()) {
        int id = aWTEvent.getID();
        switch (id) {
          case KeyEvent.KEY_PRESSED:
            kl.keyPressed(evt);
            break;
          case KeyEvent.KEY_RELEASED:
            kl.keyReleased(evt);
            break;
          case KeyEvent.KEY_TYPED:
            kl.keyTyped(evt);
            break;
          default:
            System.err.println("Unhandled Key ID: " + id);    
        }
      }
    }
  }
};

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

/**
   * Forwards <code>event</code> to all listeners whose 
   * {@link bibliothek.gui.dock.DockElement} is above the component
   * on which the event occurred.
   * @param event the event to send
   */
  protected void fireKeyTyped( KeyEvent event ){
    if( !event.isConsumed() ){
      DockElementRepresentative representative = controller.searchElement( event.getComponent() );
      if( representative != null ){
        DockElement element = representative.getElement();
        List<KeyboardListener> list = keyListeners.affected( element );
        loop:for( KeyboardListener listener : list ){
          if( listener.keyTyped( element, event )){
            event.consume();
            break loop;
          }
        }
      }
    }

    for( KeyListener listener : globalListeners.toArray( new KeyListener[ globalListeners.size() ] )){
      listener.keyTyped( 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);
}

相关文章