Problem responding to events in fullscreen mode

I made a fullscreen game and I'm trying to get it to respond to the mouse or keyboard input. The problem is it only responds a few second after I press the button. Does anyone know how I could speed up the response? All my code is posted below.
EDIT: I did some experimenting and it looks like device.isDisplayChangeSupported() returns false and the resolution never gets changed to 800x600 (I haden't noticed this before since I was flooding the whole screen with black). I also took a look at the resolutions I could manually set the monitor to and it only shows 1280x800 and 1024x768. This is under Ubuntu Linux. Even though I haven't run this program under my Windows installation, I'm sure I can change to 800x600 resolution there since I've done it manually and through other programs. Does anybody know any solutions to this? I will probably try running the program under Windows and see what happens.
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferStrategy;
public class LostHaven implements KeyListener, MouseListener
     private static DisplayMode[] BEST_DISPLAY_MODES = new DisplayMode[] {
        new DisplayMode(800, 600, 32, 0),
        new DisplayMode(800, 600, 16, 0),
        new DisplayMode(800, 600, 8, 0)
    Frame mainFrame;
    boolean done;
    boolean pressed;
    public LostHaven(GraphicsDevice device)
        try
            GraphicsConfiguration gc = device.getDefaultConfiguration();
            mainFrame = new Frame(gc);
            mainFrame.setUndecorated(true);
            mainFrame.setIgnoreRepaint(true);
            device.setFullScreenWindow(mainFrame);
            if (device.isDisplayChangeSupported())
                chooseBestDisplayMode(device);
            mainFrame.addMouseListener(this);
            mainFrame.addKeyListener(this);
            mainFrame.createBufferStrategy(2);
            BufferStrategy bufferStrategy = mainFrame.getBufferStrategy();
            done = false;
            pressed = false;
            while (!done)
                Graphics g = bufferStrategy.getDrawGraphics();
                render(g);
                g.dispose();
                bufferStrategy.show();
        catch (Exception e)
            e.printStackTrace();
        finally
            device.setFullScreenWindow(null);
    private void render(Graphics g)
         Rectangle bounds = mainFrame.getBounds();
         g.setColor(Color.black);
        g.fillRect(0,0,bounds.width, bounds.height);
        g.setColor(Color.red);
        g.fillRect(bounds.width*1/4, bounds.height*1/4, bounds.width*2/4, bounds.height*2/4);
        if(pressed)
             g.drawString("mouse pressed", 0, 15);
    private static DisplayMode getBestDisplayMode(GraphicsDevice device)
        for (int x = 0; x < BEST_DISPLAY_MODES.length; x++)
            DisplayMode[] modes = device.getDisplayModes();
            for (int i = 0; i < modes.length; i++)
                if (modes.getWidth() == BEST_DISPLAY_MODES[x].getWidth()
&& modes[i].getHeight() == BEST_DISPLAY_MODES[x].getHeight()
&& modes[i].getBitDepth() == BEST_DISPLAY_MODES[x].getBitDepth()
return BEST_DISPLAY_MODES[x];
return null;
public static void chooseBestDisplayMode(GraphicsDevice device)
DisplayMode best = getBestDisplayMode(device);
if (best != null)
device.setDisplayMode(best);
     public void mousePressed(MouseEvent e)
     pressed = true;
     public void mouseReleased(MouseEvent e)
     public void mouseEntered(MouseEvent e)
     public void mouseExited(MouseEvent e)
     public void mouseClicked(MouseEvent e)
     public void keyTyped(KeyEvent e)
     public void keyPressed(KeyEvent e)
          if(e.getKeyCode() == KeyEvent.VK_ESCAPE)
               done = true;
     public void keyReleased(KeyEvent e)
     public static void main(String[] args)
          try
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();
LostHaven gameWindow = new LostHaven(device);
          catch (Exception e)
               e.printStackTrace();
System.exit(0);
Message was edited by:
Japheth

Do you get this behavior when it's not fullscreen (and the rest is the same)?

Similar Messages

  • Runnning MAC OS X (Lion 10.7.5). I bookmarked sites I frequent to display beneath address bar. Problem: When I go to fullscreen mode, they disappear.

    When I go to fullscreen mode, all my bookmarks disappear. When I minimize the window, they reappear.
    My question is: How do I keep my bookmarks ontop/displayed so that when I'm in fullscreen mode, I don't have to minimize the window to click on a bookmark then go back to fullscreen mode.
    The autohide mode during fullscreen I do not mind just the issue with my bookmarks disappearing during fullscreen mode

    Please update to Firefox 17.0.1 then try again. The version you are running is known to be buggy. [[Update Firefox to the latest version]]

  • How to add extra functionalities to ESC key event on fullscreen mode of flash player

    Hi everyone,
    I have a typical problem.
    I want to do something additional with what the esc key does when we are in full screen mode of flsh player.
    Normally the esc key exists from the full screen.
    But along with that i want to resize one my panel inside my flash app.
    so pls help me to solve this

    Hi there,
    I think the answer is lay in where
    dcm = new DirectColorModel(bits, bm, gm, rm, am);
    Notice, rm and bm swapped.
    public DirectColorModel(int bits,
    int rmask,
    int gmask,
    int bmask,
    int amask)
    * this is the default setting
    Hence I guess using compare function before the line of dcm e.g. say if rmask and gmask = some color value, set othermask to blah blah blah...BLAH BLAH BLAH. Hope you will find your answer. somehow

  • Problem with Adobe Flash Player in fullscreen mode

    Hi everybody, I have noticed a problem with flash player while I'm watching streaming programs in fullscreen mode.
    The problem is that when I'm watching something in fullscreen mode and the quality is set to "high" I have a stammer in both sound and image.
    When I 'm watching in "medium" quality everything is fine in fullscreen mode.
    The default selection is "high", how can I change this to "medium" ?
    It's very annoying to change this all the time manually.
    thxx in advance
    p.s. I use windows 7 64bit ultimate and the latest version of both firefox and adobe flash player

    So, you didn't need help with anything, you just wanted to rant?

  • Problem with Fullscreen mode

    Hello. I have problem with Fullscreen mode in Pages 09. Let me explain it. I launch Pages 09 on space nr 4, than i activate fullscreen mode and now when fullscreen is active i switch for example to space nr 2. And what happens? Pages also moves to space nr 2, but i don't want to move my pages to space nr 2. I guess it is a bug in Pages 09. Thank you for your advice.

    Hi There
    By the sounds of this behaviour you haven't set any space options for Pages within System Preferences (Expose and Spaces Pane). After experimenting with different options this is what I experience:
    1. Pages not listed in application assignment in spaces Preferences - Enter full screen in pages, switch from one space to another pages window will follow and exit fullscreen (this sounds like what you are experiencing).
    2. Pages set to every space in app assignment - Enter full screen in pages, switch from one space to another and pages will follow but wont exit full screen.
    3. Pages set to a single space in app assignment - Enter full screen in pages, switch from one space to another using control and arrow keys pages will pull me back into the space it is set to and will exit fullscreen. Using the control and number keys pages will stay in its set space but upon returning to that space pages had exited fullscreen.
    I suggest you add pages to the the spaces application assignment in System Preferences by clicking the plus arrow under the list of apps and select a specific space for pages to open in, once open Pages will only move from this space if you move it manually.
    You can send your feedback to Apple via http://www.apple.com/feedback/pages.html if you wish
    Hope this helps
    J.C

  • "ESC" event keycode not detected in document.keydown listener while exiting fullscreen mode

    I have a code to fire on exiting full screen mode.
    Therefore, i bind it to :
    # (window.document).keyup(function(e) {
    # if(e.keyCode === 27 ) {
    # // do something //
    Now, When i am in fullscreen mode,
    1. When i press "ESC", Fullscreen mode exits but my function does not gets fired.
    2. When i press "ESC" after fullscreen mode have exited, My function gets fired.
    That means "ESC" event was not propagated to code when browser was in fullscreen mode.
    ( * This works correctly in chrome )
    3. This is bit too much too ask, but can i bind browser's exit full screen button which appears at the top ??

    If you are using HTML5, I think the way to do is to bind with the fullscreen APIs that are still in''progress''. You could try these two links to see if that helps you
    #[http://www.sitepoint.com/html5-full-screen-api/ HTML5 Full screen API]
    #[https://wiki.mozilla.org/Gecko:FullScreenAPI Mozilla support for fullscreen]
    #[http://www.sagarganatra.com/2012/05/using-html5s-fullscreen-api.html HTML5 fullscreen API]
    You could create an event listener for the document.cancelFullScreen() and then see if that helps.
    Any specific reason why you want to bind to the button and not to the event?

  • My PC is not responding when i put an iTunes LP in Fullscreen mode

    My PC is not responding when i put an iTunes LP in Fullscreen mode but it just only freeze and i need to disconnect mi Pc  help

    i thing that you have to dowlound in other page

  • My iMac screen suddenly turn black and white when I'm in fullscreen mode. What could be the cause of this problem?

    Hi, once in a while the screen on my 5K imac turns black and white when I'm on youtube watching videos in fullscreen mode. It also exits the fullscreen mode automatically from one second to the next and a warning pops up saying how I can exit the fullscreen mode. Does anyone have an idea why this happens and if this is a software or hardware problem?

    I'm using a Dell laptop with Windows 7. I've set the resolution to 1024x768, though the maximum resolution on this can go as high as 1366x768. So this is a problem that no one has been able to figure out? I've ran lots of other Flash-based applications that went fullscreen with no problem, so I'm wondering what other methods there are to try, if possible.

  • When I run a application in fullscreen mode while using the Firefox browser, the application automatically minimizes, e gets back to normal only if I close the Firefox. How can I solve this problem?

    Hello, I'm writing it to inform you that I am having some problems with mozilla firefox 3.6.10, and I know that other people are having the same problem: Ever I run any fullscreen application, like games, while using mozilla firefox 3.6.10, it automatically minimizes (the program, not the browser). I'd like to find a solution. Sorry about the bad english, I'm a brazilian. My operational system is Windows 7 x86, and I have a Pentium E5300 processor, motherboard MSI (MS-7267), and 2GB of RAM DDR2. It's a Desktop Computer. Thanks for all.

    See comments 17,44,63,71:
    * [https://bugzilla.mozilla.org/show_bug.cgi?id=627729 Bug 627729] - Hotmail web page continually reloads every second
    ''(please do not comment in bug reports; you can vote instead)''

  • Runnng external swf Actionscript while in fullscreen mode

    I am using Flash 9.0 (CS3 Pro). I am coding in Actionscript
    3.0
    I have two swf files, both interactive. During playback of
    the, a mouse event launches the second. I also want the mouse event
    to trigger a switch to fullscreen mode. The second swf is
    non-linear and requires user input to jump to the appropriate frame
    of the timeline. Everything tests and runs perfectly during
    standard screen mode but whenever I try to load and play the
    external swf file in fullscreen mode, Flash recognizes the
    actionscript built into the original SWF but ignores all of the
    Actionscript (this.stop(), this.gotoAndPlay(), etc.) embedded in
    the second (external) swf file.
    How can I get external swf files to load with their scripted
    functionality in fullscreen mode?
    Thanks for the help.
    Aaron
    The code I am using is:
    // --- this is the code contained in the first swf file
    // function to launch second SWF file
    function movieLaunch(event:MouseEvent):void
    // Sets display mode to fullscreen. With this line present,
    Flash does not look at any Actionscript in ip.swf
    // If I comment the below line out, the second SWF plays
    correctly and has full functionality
    stage.displayState = "fullScreen";
    // load and launch second movie (ip.swf) which is located in
    the same directory
    var request:URLRequest = new URLRequest("ip.swf");
    var loader:Loader = new Loader();
    loader.load(request);
    addChild(loader);
    // Sets the listener for the button that will launch the
    second movie.
    launchMovieButton.addEventListener(MouseEvent.CLICK,
    movieLaunch);
    Text

    The keyboard is disabled in fullscreen mode. This may be
    causing the problem?

  • Bug's found in fullscreen mode.

    Hello i have discovered a bug in flash or in iexplorer the
    fullscreen mode.
    Problem 1: onMouseUp event fails in fullscreen mode (when
    published in html mode).
    First of all, when i placed a button on the stage to go
    fullscreen the onMouseUp event will not be triggered.
    I only listens to the onMouseDown event. Fortuneately the
    event of the button (onRelease) will be triggered so i have found a
    work around for this. This effect happens when published to an html
    only. In firfox and IExplorer.
    Problem 2: When using a custom mouse in fullscreen mode, the
    mouse will go very slow or shocking..
    The second bug has to do with some rendering i think. The
    strange thing is when you run the swf localy and you are in
    fullscreen mode the mouse will move smooth. But when i publisch it
    to html mode and upload this html and look it online, the custom
    mouse will move very slow and not smooth. In firefox it moves a lot
    better..
    Has anyone experienced this problem too and find a work
    around?
    To expierence this problem look at my website :
    flash website with
    custom mouse
    I hope someone has a solution.. (i also removed the effects
    like blur and motion on the custom mouse ..but still the mouse will
    moves not smooth).
    Regards.

    I can see the menu if I select the screen mode "Full Screen with Menu Bar"
    Additionally, why don't you just hit Cmd + Tab (mac) or Alt + Tab (Win) to switch between applications quickly?

  • Exe Fullscreen mode kiosk question

    We develop Flash demos for touchscreen kiosks and export them to a exe file, then run in fullscreen mode which works great, except for when windows has an update or anything notification in general it pulls the exe out of fullscreen mode and makes the desktop accessible. So I guess what I am really asking is if anyone else has encountered this problem, or would know a solution for locking the exe in fullscreen mode unless esc is pressed (there is a keyboard locked in the kiosk) no matter what is happening with the operating system.
    Thanks in advance for any advice given!!

    thanks for responding Tiago,
    I realize this isn't something that Flash is responsible for, I was just hoping to find someone who has encountered the same problem and who they were able to correct it. Since we have numerous kiosks out there that need this corrected switching to AIR would have to be a last resort, but I plan on looking into it for future projects.
    Thanks again and i will post the product or solution that we use!

  • How to I get iPhoto to stop opening in fullscreen mode?

    Every time I open iPhoto, it opens in fullscreen mode. It's as if there is a setting that has been set for it to do it(though I've checked the settings and there's no such thing). I usually exit fullscreen mode in the usual way and it cooperates, but then sure enough, the next time I open it up, it's in fullscreen mode again. Additionally, perhaps it is linked to this problem, everytime I open iPhoto, it tells me that "iPhoto has detected inconsistencies in your[my] library" and that I should "click Repair to avoid any potential problems". I've clicked repair numerous times but it still gives me the same message the next time I start the program. I've tried deleting the iPhoto plist file and that has not helped either.
    Another side note that may be similar is that Terminal always opens in fullscreen just like iPhoto.

    Alright, I fixed the problem!
    A more in depth description of the process, some credit for its origins, why it works, and how else you can use it can be found here:
    https://discussions.apple.com/message/17269094#17269094
    But basically, you do the following:
    1. Navigate to "~/Library/Saved Application State/"
    2. Find "com.apple.iPhoto.savedState"
    3. Move it to the Trash
    4. Launch iPhoto
    Also, to solve the issue involving "Repairing" the Library, I had to navigate to the file "iPhoto library" (in ~/Users/dro8654/Pictures) and edit its "Sharing & Permissions" preferences such that only MY user was allowed to "Read & Write"
    This discussion was what helped me with this:
    https://discussions.apple.com/message/17261957#17261957

  • How can I see my movie in FullScreen mode

    Hello everyone,
    I've converted all my divx and other DVD Rip (home made) with AVS Video Converter Pro in order to import them in iTunes ... I try to see one oh these movies with my Apple TV thanks to my shared iTunes Library ... it's works but the video take only 2/3 of my TV screen ... I've got a 46" and 36" but this problem appear on both.
    I want to see my movie on FullScreen mode not only 2/3
    I checked video format and it's the same as the original movie (I tried to show this movie thanks to my Playstation 3 and it works in FullScreen .... but I want to use Apple TV for all my music and movies instead my Play Station
    So is there any option or anything to do to enable FullScreen mode for my video ... do I have to convert my DivX in an other format ?
    Thanks for your help
    PS : I've got the last Apple TV and I downloaded the last upgrade early.
    Thanks & Regards
    Cyril

    How can it be possible because the resoution of my video source is the same before and after conversion process ... thanks to my ADSL Box and my PS3 the video is ok ... not with ATV ...
    Could you please give me the resolution I should have for my video in SD or HD720 ?
    All my video have converted in 768x576 ...
    Is there another way to convert my video for iTunes instead AVS Video Converter ?
    Thanks all

  • When in fullscreen mode, bottom of Firefox window ends where Windows Taskbar would be, were it not in autohide mode.

    Firefox version: 4
    Windows Version: XP-SP3 (automatic updates)
    My Windows Taskbar is in autohide mode.
    When I launch Firefox in windowed mode and maximize the window, it takes up the entire screen.
    When I move my mouse pointer to the bottom of the screen, the Windows Taskbar pops up.
    When I select Fullscreen mode in Firefox, the top of the window behaves as it should: Menus disappear, and the toolbar area autohides, reappearing when I move my mouse pointer to the top of the screen.
    The bottom of the Firefox window, however, jumps up to where it would be if the Windows Taskbar were not in autohide mode, leaving a black space. While I can move my cursor over this black space, when I reach the bottom of the screen, the Windows taskbar will not unhide, forcing me to use the Windows button if I want to execute some other command.
    If I minimize the Firefox window, then select it from the taskbar, it returns to fullsceen mode and takes up the entire screen (no more black space), but I still cannot get the Windows Taskbar to pop up by moving my cursor to the bottom of the screen.
    While it may seem nit-picky, this is a dealbraker for me. I set Firefox to run in Fullscreen mode, and expect it to do so properly, without having to go through all of these steps. Furthermore, since I use Windows Start button for everything (my desktop has nothing on it but the Recycle Bin), I often use it while browsing (launching other applications, using the Control Panel, or looking through filesystem, among others).
    I am extremely pleased with all other aspects of the browser, right down to the toolbar area not disappearing when my mouse pointer happens to slide off of it after I place my cursor in the search box, and while I would be sad to lose all of these improvements, I will return to Version 3 if I must.
    Thank you very much for your time.
    ~David Morrissey~

    I'm sorry, it seems I spoke too soon. The original problem is back: Black stripe at the bottom of the screen. :-(

Maybe you are looking for

  • Is there a way to contact Lightroom help by phone? I have a complicated issue with missing files.

    When I downloaded my photos into Lightroom today I used today's date on the folder, but got the year wrong, 2013. After I completed editing my entire photo session, and tried to export some of the images, I realized I had the date wrong on the folder

  • Creative live cam voice help please

    Help please, We are using the "live cam voice" model, with our computer (Vista 32bit), that appears to work OK, but after a few minutes we get the BSOD! We have tried un installing and re-installing drivers without any effect.Has anyone had this prob

  • InD 6 file color different in Acrobat

    I set my color profile in Bridge so all programs in CS6 sync. Images I build in Pshop (RGB 6x9@300 res) retain color when imported into InD. If I export the InD file as jpg, image also retains color. But when I export same InD file as PDF, the color

  • Passing information

    I am trying my hand at programmatic skinning of components. I have created a class for the up-state of a TabBar component (The Yahoo ASTRA TabBar), and I have the need to style this at runtime based on XML. I never create an instance of the class any

  • Shutting down problem with Satellite A300

    Hello, I have a problem in shutting down my laptop. Whenever I shut it down it looks everything is ok, but as soon as I close the lid it turns automatically on. This is very annoying. Anyone knows the solution? Thank you.