# The Jedi Tutorial

previous | by Andreas Raquet | next

### Easy image access

Loading images from the filesystem to include them in a GUI is easily accomplished in java. When creating an applet things become more complicated as applets are not generally allowed to read from a local filesystem. The problem is avoided by creating a `jar` file that contains java classes and icons. From the commandline this is quite easy, but for a integrated enviroment special support is required.

### Importing icons

The first step to use external icons is to import them into Jedi. Click the 'Images' tab. Jedi will show you a large (empty) list, a preview area on the right and a little button. First import an image by opening the right-mouse-menu and selecting 'from filerequester'. Go to the Jedi installation directory and select '`tutorial/DeskGlobe.gif`'. The path will appear in the image list. Select it and a preview will be shown in the preview panel.
That is all that is needed to import images. From now an all `jar` files created for this project will contain the '`DeskGlobe.gif`' image. Note, however, that Jedi does not copy images to its own directory structure. This means when compiling a project all images must be present in the paths specified in the list.

### Using icons

To use an image, we must first know how to load it. A classloader is used to do the work, but you do not need to implement it. Select the 'GUIWorld' class with the mouse and click on the little 'create image loader' button on the lower right. A new method called 'getIcon' will appear . Calling it with the name of your icon (not the path) will return the Imageicon object we can then use in our application.
Select the 'getGlobe' which only contains...``

`return null;`

replace this line with...

`return getIcon("DeskGlobe.gif");`

When you recompile and launch GUIWorld now, the example icon will be displayed in the HelloWorld frame. Note, that the actual use of the icon, i.e. the creatiuon of a button hat contains the icon, takes place in the GUIWorld constructor. The icon import has been seperated to make it easier to understand for Java beginners.

You are now able to import and use images in your project. Now let us get to support for multiple languages.

previous | 30.08.1999 | next