Results 1 to 2 of 2
  1. #1
    AnOdeToCode is offline Member
    Join Date
    Nov 2008
    Location
    India
    Posts
    1
    Rep Power
    0

    Default 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()........
    }

  2. #2
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default 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

  1. XTerm window appearing in full screen swing app
    By clarose in forum AWT / Swing
    Replies: 1
    Last Post: 11-17-2008, 10:56 PM
  2. Open a shell maximized (full screen)
    By Java Tip in forum SWT Tips
    Replies: 0
    Last Post: 07-25-2008, 02:27 PM
  3. Full screen test
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 11:24 PM
  4. how to set full screen dimensions
    By valery in forum New To Java
    Replies: 1
    Last Post: 08-03-2007, 06:08 PM
  5. Full screen
    By Jack in forum Advanced Java
    Replies: 2
    Last Post: 07-02-2007, 05:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •