Full screen with KeyListeners

sorry to post Noob question but i am really getting in a twist over this and i can’t seem to find anything on any forums.

I have a very simple full screen app and i just want a convenient way of closing it, i have very little user input i a simple keyListener seems like the best option.

I am setting up full screen as follows:

(this has been extracted so that is readable context free)


frm = new JFrame();

GLCanvas des = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());

win = new Window(frm);

win.add(des);

// ...  set size, set visible etc.

GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(win);


I have tried adding keylisteners to the frame, the window and the canvas, i have tried making various parts unfocusable and requesting focus on others. The only time I have managed to get it working was by adding a Frame/JFrame to the ScreenDevice.setFullScreenWindow(); and addling the listener to that. However this results in the menu bar being visible and I wanted that hidden.

Please tell me what I am doing wrong, i’m sure i’m nearly there and this is frustraiting.

Thank you,

I have deoderised my code a bit, but I still have the same problem:


 
GLCanvas des = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
 
JWindow win = new JWindow();
 
win.add(des);
 
// ...  set size, set visible etc.
 
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice ().setFullScreenWindow(win); 


No more redundant frame hanging around, but still no responce from the kayboard listeners :frowning:

You can look at the jogl port of Nehe demos, they handle keylisteners in full screen mode.

Edit : Basically you have to add your keylistener on the glcanvas.

Thanks for your help, unfortunatly i have alrerady tryed this and have been using the website you refrence. Perhaps I am doing something wronge, her is the code I am using for adding a Listener:


            
des.addGLEventListener(this);            
des.addKeyListener(this);

this.setFocusable(false);
//this.requestFocus();
des.requestFocus();
// i have played around with altering focus settings
// this is the one I would have thought would have worked
// but it didn't :/ 


Note: “this” refers to the JWindow I am extending to controle the GLCanvas, it overides boh keyEventListerner and GLEventLsitner

I would Also Like to add that further poking has descoverd that the falure to respond seem to be an artifact of me using a Window instread of a frame as when i disable full screen but still use a Jframe I have the same problem. Is there some way that JWindows handle focuse diffrently?

I have found a solution:

course:

A JWindow cannot have focus without it’s owing frame being visible (in the situation where i was not crating my own owner frame one was actually being created anyway).

Solution:

Don’t use JWindow use a JFrame and call the method setUndecorated(true);

Sorry to have wasted your time,

Edited for spelling ><