Results 1 to 4 of 4
  1. #1
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default Loading Game Screen.

    Cannot get a loading screen to pop up when using sleep (Making it look like it's loading).
    Why can't I do this? After the loading screen it's supposed to go to another page.
    But first it stops on the menu screen. Then it just jumps over to the other page?
    Why? How can I fix it?

    Kind,
    Regards Alexander Hållenius
    Currently Developing a Game Called Loaie, You Can Download It From "The Loaie Website".

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Loading Game Screen.

    Is your code blocking the GUI's thread?
    Post some sample code so we can see what you are doing.

  3. #3
    Alerhau's Avatar
    Alerhau is offline Senior Member
    Join Date
    Jun 2011
    Location
    Sweden
    Posts
    158
    Rep Power
    4

    Default Re: Loading Game Screen.

    *Clicking Menu Button*

    Java Code:
    Menu.setVisible(false);
    Loading.setVisible(true);
    add(Loading);
    
    try{
         Thread.sleep(4000);
    } catch(Exception e) {}
    
    Loading.setVisible(false);
    NextScreen.setVisible(true);
    add(NextScreen);
    Currently Developing a Game Called Loaie, You Can Download It From "The Loaie Website".

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Loading Game Screen.

    Sorry, I meant a SSCCE that we can compile and execute to see the problem.

    The sleep in your code will block the thread. If it is the GUI's EDT then nothing happens on that thread until your code returns. Try using a Timer in place of the sleep. The code after the sleep should be moved to the Timer's action method to be executed after the Timer has fired.

Similar Threads

  1. Chess game selection screen
    By gruffyddd in forum AWT / Swing
    Replies: 1
    Last Post: 03-19-2011, 03:27 AM
  2. First Java game: Why is screen painting so slow?
    By CoderMan in forum Java Gaming
    Replies: 5
    Last Post: 05-20-2010, 02:55 AM
  3. Loading screen using splash windows
    By andres3546 in forum Advanced Java
    Replies: 1
    Last Post: 10-27-2009, 08:27 PM
  4. Replies: 2
    Last Post: 04-03-2009, 05:04 AM
  5. Blank Screen while navigating from one screen to another
    By mohana.krishna in forum Java Servlet
    Replies: 0
    Last Post: 03-03-2009, 05:03 PM

Posting Permissions

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