Java JOGL,com.jogamp.newt.event.KeyListener问题

Java JOGL,com.jogamp.newt.event.KeyListener问题,java,keypress,keylistener,jogl,keyrelease,Java,Keypress,Keylistener,Jogl,Keyrelease,因此,我们的应用程序结构如下: 在EC_GUI构造函数中,我初始化了glViewer private void initGlViewer() { /** * Viewer. */ glViewer = new GLViewer(); glViewer.setup(); centerPanel.add(glViewer.getNewtCanvasAWT()); } glViewer

因此,我们的应用程序结构如下:

在EC_GUI构造函数中,我初始化了glViewer

    private void initGlViewer() {
        /**
         * Viewer.
         */
        glViewer = new GLViewer();
        glViewer.setup();
        centerPanel.add(glViewer.getNewtCanvasAWT());
    }
glViewer实现了GLEventListener,如下所示

    public GLViewer() {

        GLProfile gLProfile = GLProfile.getDefault();

        GLCapabilities gLCapabilities = new GLCapabilities(gLProfile);

        glWindow = GLWindow.create(gLCapabilities);
        /*
         *  We combine NEWT GLWindow inside existing AWT application (the main JFrame) 
         *  by encapsulating the glWindow inside a NewtCanvasAWT canvas.
         */
        newtCanvasAWT = new NewtCanvasAWT(glWindow);
    }
在glViewer.setup中,我将鼠标、键和glEvent侦听器添加到glViewer窗口

我正在使用com.jogamp.newt.event中的键和鼠标事件

My keyListener中的My keyPressed事件启动为:

@Override
    public synchronized void keyPressed(KeyEvent ke) {
        System.out.println("keyPressed " + ke.getKeyCode());
钥匙也松开了

嗯,有时候我在触发方面遇到了矛盾。让我们以按下组合键ctrl+o打开文件选择器为例

这应该是:

keyPressed 17
List of pressed inputs
ctrl
keyPressed 79
List of pressed inputs
ctrl
o
keyReleased 17
keyReleased 79
2014.10.09, 10:53:49  [INFORMATION]  Open a project ...
2014.10.09, 10:53:49  [INFORMATION]  Opening file chooser for load.
2014.10.09, 10:53:55  [INFORMATION]  User clicked 'cancel' in file chooser dialog.
在这里你可以看到我按下ctrl 17,然后按o 17,它们都被释放,文件选择器被显示。然后我退出,正如你在最后一行看到的

但有时我得到的是:

keyPressed 17
List of pressed inputs
ctrl
keyPressed 79
List of pressed inputs
ctrl
o
keyReleased 17
2014.10.09, 10:57:34  [INFORMATION]  Open a project ...
2014.10.09, 10:57:34  [INFORMATION]  Opening file chooser for load.
2014.10.09, 10:57:35  [INFORMATION]  User clicked 'cancel' in file chooser dialog.
keyPressed 17
List of pressed inputs
ctrl
keyReleased 79
2014.10.09, 10:57:36  [INFORMATION]  Open a project ...
2014.10.09, 10:57:36  [INFORMATION]  Opening file chooser for load.
2014.10.09, 10:57:38  [INFORMATION]  User clicked 'cancel' in file chooser dialog.
我按下了ctrl键和o键,但错过了其中一个释放的键,在本例中是o键。无论如何,文件选择器仍然会被打开。在下一次尝试中,我再次按下ctrl+o,但这次我错过了按下的o键。我还错过了释放的ctrl键。无论如何,文件选择器仍然会打开。 但有时它不会打开,例如:

keyPressed 17
List of pressed inputs
ctrl
keyPressed 79
List of pressed inputs
ctrl
o
keyReleased 17
2014.10.09, 11:08:57  [INFORMATION]  Open a project ...
2014.10.09, 11:08:57  [INFORMATION]  Opening file chooser for load.
2014.10.09, 11:08:58  [INFORMATION]  User clicked 'cancel' in file chooser dialog.
keyPressed 17
List of pressed inputs
ctrl
keyReleased 79
2014.10.09, 11:08:59  [INFORMATION]  Open a project ...
2014.10.09, 11:08:59  [INFORMATION]  Opening file chooser for load.
2014.10.09, 11:09:02  [INFORMATION]  User clicked 'cancel' in file chooser dialog.
keyReleased 79
keyReleased 17
keyReleased 79
我按下ctrl键、o键、ctrl键释放、无o键释放,打开文件选择器,然后关闭它。 我再次按下它们,按下ctrl键,没有按下o键,o键释放,没有ctrl键释放,文件选择器打开,然后我再次关闭它。 我再次按下ctrl+o,我没有按下任何键,我只是得到一个o键释放,一个ctrl键释放,然后另一个o键释放。FileChooser这次没有打开


有什么线索吗?

我通过在每个按键按下/按键释放事件中检查按下的修饰符来解决问题,方法是按按键事件查询每个X修饰符。isXDown

这里已经问过问题:请提供单元测试并填写错误报告。@gouessejdone@gouessej确切地: