本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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();
}
}
示例5: addKeyListener
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public void addKeyListener(KeyListener listener) {
keyListeners.add(listener);
}
示例6: removeKeyListener
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public void removeKeyListener(KeyListener listener) {
keyListeners.remove(listener);
}
示例7: getKeyListeners
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public ArrayList<KeyListener> getKeyListeners() {
return keyListeners;
}
示例8: getKeyListener
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public KeyListener getKeyListener() {
return resolver;
}
示例9: keyPressed
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
if (!enabled) return;
resolveKeyEvent(e, KeyListener::keyPressed);
}
示例10: keyReleased
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyReleased(KeyEvent e) {
if (!enabled) return;
resolveKeyEvent(e, KeyListener::keyReleased);
}
示例11: getKeyListener
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public KeyListener getKeyListener() {
return ui.getKeyListener();
}
示例12: keyPressed
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
resolve(e, KeyListener::keyPressed, controller::keyPressed);
}
示例13: keyReleased
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
@Override
public void keyReleased(KeyEvent e) {
resolve(e, KeyListener::keyReleased, controller::keyReleased);
}
示例14: NEWTKeyAdapter
import com.jogamp.newt.event.KeyListener; //导入依赖的package包/类
public NEWTKeyAdapter(KeyListener _l) {
l = _l;
}
示例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);
}