Results 1 to 2 of 2
- 11-25-2008, 08:12 AM #1
Member
- Join Date
- Nov 2008
- Location
- India
- Posts
- 1
- Rep Power
- 0
Full-Screen Window is not supporting KeyListener
The KeyListener works for the Frame, but doesnt seem to work for Window...?
public abstract class AbstrScreen
{
protected GraphicsDevice gDevice = null;
protected GraphicsConfiguration gConfig = null;
protected GraphicsEnvironment gEnv = null;
protected Window screen = null;
protected Frame frame = null;
protected KeyListenerImpl keyListener = null;
protected void initGraphics() throws GraphicsError
{
gEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
gDevice = gEnv.getDefaultScreenDevice();
if(!gDevice.isFullScreenSupported())
{
throw new GraphicsError("Full Screen Mode not supported by Graphics Driver!");
}
gConfig = gDevice.getDefaultConfiguration();
frame = new Frame("");
frame.setLayout(null);
frame.setBackground(Color.YELLOW);
frame.setVisible(false);
screen = new Window(frame, gConfig);
screen.addKeyListener(keyListener);
screen.setFocusable(true);
gDevice.setFullScreenWindow(screen);
}
}
public class KeyListenerImpl implements KeyListener
{
public void keyPressed(KeyEvent ke)
{
System.out.println(ke.getKeyCode());
if(ke.getKeyCode() == 27)
{
System.exit(0);
}
}
keyReleased()......
keyTyped()........
}
- 02-13-2009, 08:08 PM #2
Senior Member
- Join Date
- Jul 2008
- Posts
- 125
- Rep Power
- 0
How and WHEN a window gains focus
The window will respond to key actions after
it meets 3 requirements.
You can find these in the API under the
AWT.Window.isFocusableWindow() method.
FIRST, set the window's focusable Window
state to true. You have done so by using:
screen.setFocusableWindowState(true);
The next two conditions seem a little odd:
The window's nearest owning Frame or Dialog
must be showing on the screen.
Your window cannot get focus because your
code has the window fill the whole screen,
so it hides everything.
AND FINALLY, that Frame or Dialog must
contain at least one Component in its focus
traversal cycle.
MY OPINION:
If you want conplete control of the screen,
using a window is not the way to go.
Similar Threads
-
XTerm window appearing in full screen swing app
By clarose in forum AWT / SwingReplies: 1Last Post: 11-17-2008, 10:56 PM -
Open a shell maximized (full screen)
By Java Tip in forum SWTReplies: 0Last Post: 07-25-2008, 02:27 PM -
Full screen test
By Java Tip in forum java.awtReplies: 0Last Post: 06-23-2008, 11:24 PM -
how to set full screen dimensions
By valery in forum New To JavaReplies: 1Last Post: 08-03-2007, 06:08 PM -
Full screen
By Jack in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 05:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks