当前位置: 首页>>代码示例>>Java>>正文


Java KeyListener类代码示例

本文整理汇总了Java中com.jogamp.newt.event.KeyListener的典型用法代码示例。如果您正苦于以下问题:Java KeyListener类的具体用法?Java KeyListener怎么用?Java KeyListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


KeyListener类属于com.jogamp.newt.event包,在下文中一共展示了KeyListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
/**
 * Resolves the given event by distributing it to the overlays and the top-level controller. The
 * distribution-process stops as soon as any overlay fully consumes the event (i.e. the callback of this event
 * returns {@code true}) and thus blocks subsequent overlays from receiving this event.
 *
 * @param e        the event to resolveKeyEvent.
 * @param fn       the function to be executed for each overlay.
 * @param toplevel the top-level receiver of the event.
 */
private void resolve(KeyEvent e, KeyListenerFunction fn, Consumer<KeyEvent> toplevel) {
    ArrayList<KeyListener> listeners = getAllOverlays().stream()
            .filter(Overlay::isEnabled)
            .map(Overlay::getKeyListener)
            .filter(Objects::nonNull)
            .collect(Collectors.toCollection(ArrayList::new));

    for (int i = listeners.size() - 1; i >= 0; i--) {
        fn.call(listeners.get(i), e);
        if (e.isConsumed())
            return;
    }

    toplevel.accept(e);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:25,代码来源:TileBasedVisualization.java

示例2: keyReleased

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyReleased(KeyEvent e) {
    int code = e.getKeyCode();
    switch (code) {
        case 0xd:
            code = java.awt.event.KeyEvent.VK_ENTER;
            break;
        case 0x95:
            code = java.awt.event.KeyEvent.VK_LEFT;
            break;
        case 0x97:
            code = java.awt.event.KeyEvent.VK_RIGHT;
            break;
        default:
            break;
    }

    KeyStroke keyStroke = KeyStroke.getKeyStroke(code, e.getModifiers());
    if (KeyShortcuts.handleKeyStroke(keyStroke, e.getSource(), java.awt.event.KeyEvent.KEY_PRESSED))
        return;

    ImageViewerGui.getCurrentInteraction().keyReleased(e);
    for (KeyListener listener : keyListeners)
        listener.keyReleased(e);
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:26,代码来源:InputController.java

示例3: Window

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public Window(KeyboardInputHandler aKeyboardInputHandler, MouseHandler aMouseHandler) 
{
    //m_GLWindow
    
    //ICON TEST
    //IOUtil.ClassResources res = new ClassResources(new String[]{"brick.png"}, getClass().getClassLoader(), getClass());
    System.setProperty("newt.window.icons", "grimhaus/com/G2Dj/Resource/Graphics/icon-16.png grimhaus/com/G2Dj/Resource/Graphics/icon-32.png");
    //NewtFactory.setWindowIcons(res);
    
    //Configure the GL
    Display display = NewtFactory.createDisplay(null);
    Screen screen = NewtFactory.createScreen(display, 0);
    GLProfile glProfile = GLProfile.get(GLProfile./*GL4ES3*/GL2ES2);
    GLCapabilities glCapabilities = new GLCapabilities(glProfile);
    
    //Create the GL context & create the window
    m_GLWindow = GLWindow.create(screen, glCapabilities);
    
    //Configure the window
    setTitle("G2Dj");
    setSize(1024, 768);
    setPosition(50, 50);
    setAlwaysOnTop(false);
    setDisplayMode(DisplayMode.Windowed);
    setPointerVisible(true);
    setPointerLockMode(PointerLockMode.Free);
            
    //Bypass JOGL's multithreaded event system
    m_GLWindow.setAutoSwapBufferMode(false);//timing of bufferswaps is up to me
    m_GLWindow.getContext().makeCurrent();//Ownership of the context is given to this thread
    
    //Attach window event listeners
    m_GLWindow.addWindowListener((WindowListener)this);
    m_GLWindow.addKeyListener((KeyListener)aKeyboardInputHandler);
    m_GLWindow.addMouseListener((MouseListener)aMouseHandler);
    
    GL gl = m_GLWindow.getGL();
    grimhaus.com.G2Dj.Imp.Graphics.GL.gl = m_GLWindow.getGL().getGL2ES2();
            
}
 
开发者ID:jfcameron,项目名称:G2Dj,代码行数:41,代码来源:Window.java

示例4: resolveKeyEvent

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
private void resolveKeyEvent(KeyEvent event, KeyListenerFunction fn) {
    Component component = manager.getFocus();
    while (component != null) {
        for (KeyListener listener : component.getKeyListeners()) {
            fn.call(listener, event);
            if (event.isConsumed())
                return;
        }

        component = component.getParent();
    }
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:13,代码来源:EventResolver.java

示例5: addKeyListener

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public void addKeyListener(KeyListener listener) {
    keyListeners.add(listener);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:4,代码来源:Component.java

示例6: removeKeyListener

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public void removeKeyListener(KeyListener listener) {
    keyListeners.remove(listener);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:4,代码来源:Component.java

示例7: getKeyListeners

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public ArrayList<KeyListener> getKeyListeners() {
    return keyListeners;
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:4,代码来源:Component.java

示例8: getKeyListener

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public KeyListener getKeyListener() {
    return resolver;
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:4,代码来源:UIManager.java

示例9: keyPressed

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    if (!enabled) return;
    resolveKeyEvent(e, KeyListener::keyPressed);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:6,代码来源:EventResolver.java

示例10: keyReleased

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyReleased(KeyEvent e) {
    if (!enabled) return;
    resolveKeyEvent(e, KeyListener::keyReleased);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:6,代码来源:EventResolver.java

示例11: getKeyListener

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public KeyListener getKeyListener() {
    return ui.getKeyListener();
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:5,代码来源:ScenarioAreaOverlay.java

示例12: keyPressed

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    resolve(e, KeyListener::keyPressed, controller::keyPressed);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:5,代码来源:TileBasedVisualization.java

示例13: keyReleased

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyReleased(KeyEvent e) {
    resolve(e, KeyListener::keyReleased, controller::keyReleased);
}
 
开发者ID:sgs-us,项目名称:microtrafficsim,代码行数:5,代码来源:TileBasedVisualization.java

示例14: NEWTKeyAdapter

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public NEWTKeyAdapter(KeyListener _l) {
    l = _l;
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:4,代码来源:NEWTKeyAdapter.java

示例15: keyPressed

import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    ImageViewerGui.getCurrentInteraction().keyPressed(e);
    for (KeyListener listener : keyListeners)
        listener.keyPressed(e);
}
 
开发者ID:Helioviewer-Project,项目名称:JHelioviewer-SWHV,代码行数:7,代码来源:InputController.java


注:本文中的com.jogamp.newt.event.KeyListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。