I actually wanted just a fake loading scene. For a fake loading scene, how do I make a time variable or a time Method? I'm still a fresh java programmer!

  • \$\begingroup\$ I think this question is way too broad to be useful, unfortunately. \$\endgroup\$ – user1430 Oct 19 '12 at 17:37

As fresh java programmer, at first try to have basics, then do it through an example and then you are expert (use professional libraries for your projects).

Basics #

Core Example #

Open Source Library #

EDIT: Regarding loading Scene in SLick

Slick provides a way to get this loading bar style initialisation - called deferred loading. When deferred loading is enabled all the calls to load resoures (images, sounds, music, fonts etc) are wrapped in the library to load only the explicit data required for the resource immediately.

public void render(GameContainer container, Graphics g) { 
    g.drawString("Loaded: "+lastLoaded, 100, 100);      

public void update(GameContainer container, int delta) throws SlickException { 
    if (LoadingList.get().getRemainingResources() > 0) { 
        DeferredResource nextResource = LoadingList.get().getNext(); 
        lastLoaded = nextResource.getDescription();
    } else { 
        // loading is complete, do normal updat ehere      

For more details, go through the followings

  • \$\begingroup\$ Nice links. Think I have to take a look at launch4j. But I think this does not answers the question. If I understood right, SystemNetworks wants to display a loading screen / animation in the context of slick2d / opengl. \$\endgroup\$ – tom van green Sep 27 '12 at 11:29
  • \$\begingroup\$ @tomvangreen Yes, you are right. Now i have edited my answer. \$\endgroup\$ – Md Mahbubur Rahman Sep 27 '12 at 13:59
  • \$\begingroup\$ To complete the answer. What deffered loading does in slick is, that the resource objects are instanciated directly, but not loaded. Every update frame only one resource is loaded. Normally the resource would load directly... This is a problem, when you want to display an animation or a progress bar, as normally the process is blocked (and therefore no render or update takes place) during the loading. With deffered loading, it may be that you experience some hangers (when loading big files), but generally you can display a loading bar animation in this way. \$\endgroup\$ – tom van green Sep 27 '12 at 14:01
  • \$\begingroup\$ You just have to make sure, that you only start using the resources, when they are loaded and not before. This means you need to track the state of the resource loading and skip actions, where the resources are needed, until they are loaded... \$\endgroup\$ – tom van green Sep 27 '12 at 14:03
  • \$\begingroup\$ @tomvangreen, Yes, I agree with you. \$\endgroup\$ – Md Mahbubur Rahman Sep 27 '12 at 14:10

You can use java Timer. Draw a rect somewhere on your screen as a progress bar and increase his width regarding the elapsed/remaining time, it can be done with a really simple percentage operation.

timer = new Timer(...)

yourSceneLoader can be a class in charge of handling the loading of your scenes, regarding the code above it should implements ActionListener and in the actionPerformed method:

public void actionPerformed() {
    updateProgressBar() //do the calculations in this method

You don't necessarily have to use a Timer but it's a way to achieve what you want and you can easily control how fast the progress bar progress.

Also if you want to do real loading, you can read this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.