LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: CodeBunny on March 29, 2011, 16:51:45

Title: Mouse and Keyboard input for AWTGLCanvas
Post by: CodeBunny on March 29, 2011, 16:51:45
How should I handle Mouse and Keyboard input when I've got an AWTGLCanvas running inside of a JFrame along with other components?

I get this error:

Mouse must be created before you can read events
at org.lwjgl.input.Mouse.next(Mouse.java:423)
Title: Re: Mouse and Keyboard input for AWTGLCanvas
Post by: kappa on March 29, 2011, 17:09:28
don't think you can use LWJGL Mouse and Keyboard classes when using an AWTGLCanvas as they require lwjgl's native window to function (and in this case it doesn't exist). Instead you will have to use AWT's input classes.

If however you use want to embed with AWT and still use LWJGL Mouse and Keyboard classes you will have to use the Display.setParent(Canvas) method.
Title: Re: Mouse and Keyboard input for AWTGLCanvas
Post by: CodeBunny on March 29, 2011, 17:18:56
Ah, I see. Yeah, I can't use Display.setParent(); I've got multiple AWTGLCanvases at once.