[Resolved] Problem using GLCanvas with French keyboard

Hi there ! :slight_smile:

short story :
I experience some problems using GLCanvas with French keyboard when pressing keys like “é” or “à” : the “pressed” event do not happen. ???

full story :
In my example, I made a class called MyListener.
In the “public static void main”, I build a frame with a glcanvas inside it.
I set MyListener as the keylistener of the frame and the canvas.
After that, when I press my “é”, “è”, “ç” or “à” key,
if the frame has the focus (at application start for example), then the pressed, types and released events happen,
but if the canvas has the focus (by clicking on it), then only the type and released events happen. :frowning:

Here is the minimal code to reproduce my problem (maybe you will need a french keyboard…)


import java.awt.*;
import java.awt.event.*;
import javax.media.opengl.*;
import com.sun.opengl.util.*;

public class MyListener implements
        KeyListener, GLEventListener
{

    public static void main(String[] args)
    {
        Frame frame             = new Frame();
        GLCanvas canvas         = new GLCanvas();
        MyListener mylistener   = new MyListener();
        final Animator animator = new Animator(canvas);
        
        frame.add(canvas);
        frame.setSize(640, 480);        
        frame.addWindowListener(new WindowAdapter()
            {
                public void windowClosing(WindowEvent e)
                {
                    new Thread(new Runnable()
                        {
                            public void run()
                            {
                                animator.stop();
                                System.exit(0);
                            }
                        }
                    ).start();
                }
            }
        );
        frame.setVisible(true);
        frame.addKeyListener(mylistener);
        
        animator.setRunAsFastAsPossible(false);
        animator.start();
        
        canvas.addGLEventListener(mylistener);
        canvas.addKeyListener(mylistener);
    }
    
    // constructor
    public MyListener() {}
    
    // key listener functions
    public void keyReleased(KeyEvent e) { System.out.println(e.toString()); }  
    public void keyPressed(KeyEvent e) { System.out.println(e.toString()); }  
    public void keyTyped(KeyEvent e) { System.out.println(e.toString()); }

    public void init(GLAutoDrawable drawable)
    {
        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());
    }
    public void reshape(GLAutoDrawable drawable, int x, int y, int _width, int _height)
    {
        GL gl = drawable.getGL();        
        System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR));
        System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER));
        System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION));
    }    
    public void display(GLAutoDrawable drawable) {}
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
}

Is this a bug from GLCanvas ? or maybe I made a mistake … :-\

Could you please try using a vanilla AWT Canvas and see whether it has the same problem?

What JDK version are you using? Have you tried the latest 5.0 update release and/or the JDK 6 weekly builds?

Thank you for your answer :smiley:

First, I add this line to show the JRE version :

System.err.println("Using java version " + System.getProperty("java.version"));  

And it prints (as expected):

Using java version 1.5.0_07

I will give a try to 1.6.0 like you told me. Ihope I will be able to install it :-[

Second, i thougth that GLCanvas was the AWT Canvas with GL capabilities and GLJPanel the Swing equivalent.
So is there something I missed with the vanilla thing ? Is it an alternate AWT GLCanvas ?

Anyway I tried with GLJPanel and retried with GLCanvas but now :

  • even if I do not click on the panel / canvas
  • even if there is no panel/canvas at all in the frame,
    there is no PRESSED event for “é”, “à”, etc… >:(
    This is so weird ???

I tried about 100 times to launch my original code and the minimal code with ether GLJPanel or GLCanvas.
Some time it gives me the Pressed event and sometimes not.
During those 100 tries, I tought it works only if I do not move the mouse while launching.
But this is correct for 70% of times only. There must be another reason.
And why only with those french characters “é”, “è”, “ç” and “à” ?

Still investigating… :-\

After hours of investigation, i found this page:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4490692
It seems to be the same problem that I experience.

They fixed the bug in Mustang so I will give it a try.

Good news soon I hope…

Victory !
The problem is fixed in Mustang 1.6.0-beta2 !
Merci Sun ;D