Slick Loading Image

This section I'll show you how to load an image with " PNG " extension. Let us create a project, inside the project create a new folder to hold
all the images. A picture is shown below.



Look at the SlickLoadImage project, I have created a new folder called " image ". I store all my images into that folder. The reason I do that
because it will be easier for us to manage our files.


Example



Click to Download Example

So first we create an image object to hold the Image.

Image push = null;

push is our null image object. Then we load the image into push by specifying the image location. Since we stored the image
in the same directory as our project, all we need to do is this, ("
slickloadimage/image/pushbutton.png"). If you look at the
very first image that I provided.
slickloadimage is the name of the folder our " java file" is in. Then image is the new folder
we created to store our images and finally the
name of the image we are trying to load. Recall, from the last section we
discussed whenever we want to draw objects into the screen, we have to use the
render method. Hence, inside the render
method, we have
push.draw(80,80), using that to draw the image into the screen. Notice push is the name of the image object.
More image examples in keyInput section.
 

  <Slick><Home>