Applet info



Before you use applets on your webpage, it's maybe good to know what applets are and how they generally work. When you understand how things work, it's much more easier to use them.



What applets are

Java applets are small programs which have been made by using Java-language. Most of web browser have built-in Java-engine which make possible to run Java-applets on webpage. Let's put one here immediately:

[Here should be applet which is scrolling text. But now it seems that your broswer can't run Java-applets or Java is disabled from browser preferences. Sorry!]

Of course Java-applets can do lots of different things and not just shake letters. (However, you don't need to worry about security. Java-applet can't read or write files from your disks, it can't access clipboard and it can't make network connection to any other place than to server where it was originally loaded.)

Applet programfiles have extension ".class". For example programfile of applet "HScroll" is "HScroll.class".



Problems

Java-engine is not exactly samekind in every browser. That's why some applet maybe work with one browser but exactly same applet doesn't work with some another browser. Or applet maybe work slightly different way in different environments. (In this case environment includes computer, operating system, browser and browser version and version of Java itself.)

All applets on my FreeJava-page are so small and simple that they should work in all environments without any problems.



How to use applets

Applets could be actually compared to pictures on webpage. See examples below and you will see lots of similarities:


Pictures

When you want to put picture (let's say "Lynx.jpg") on your webpage, you first copy "Lynx.jpg" to your webpage-directory and then you add this kind of line to your webpage source-code:

<IMG SRC="Lynx.jpg" WIDTH=160 HEIGHT=100 ALT="No pictures">

That line tells browser that it should download "Lynx.jpg" from server and show it on page in 160x100 area. If browser can't display pictures, it will write "No pictures" on screen instead of drawing picture.


Applets

Applets work same way. If you want to put applet called "HScroll" on your webpage, you first copy "HScroll.class"-file to your webpage-directory and then add this kind of lines to webpage source-code:

<APPLET CODE="HScroll.class" WIDTH=160 HEIGHT=100>
 No Java
</APPLET>

Those lines tells browser that it should download applet called "HScroll" and execute it on area which is 160x100 pixels. If browser can't run Java-applets, it will write "No Java" on screen.



How to use parameters

Think situation where you want to put two (or more) applets on your page. First one is scrolling text "My Page" and second is scrolling text "My Other Page". It would be stupid (and hard in some cases) to make two programs where only difference is that they scroll different texts. Easier way is to make one textscroller-applet which can read text (which should be scrolled) from parameters, like this:

<APPLET CODE="HScroll.class" WIDTH=200 HEIGHT=50>
 <PARAM NAME="Text" VALUE="My Page">
 No Java
</APPLET>
....
<APPLET CODE="HScroll.class" WIDTH=250 HEIGHT=50>
 <PARAM NAME="Text" VALUE="My Other Page">
 No Java
</APPLET>

Now you got two scrolling texts on your page, but you don't need more than one "HScroll.class"-programfile. Of course, before this works, applet "HScroll" have to support parameter named "Text". If it doesn't support it, parameter doesn't have any effect.

There can be also more parameters than just one.



Importance of parameters

Most of applets on my FreeJava-page would be more or less unuseful without parameters. "HScroll" is good example of that. If people can't define which text will be scrolled on screen, "HScroll" would be boring program scrolling same pre-programmed text all the time.

But now you don't need to know anything about Java-programming (unless you want to, it's nice language :-) because you can make programs work in way you want just by changing parameters.





Back to "Free applets"-page

Back to "Java"-page



www.tiikoni.net/java/free/info.php Full page map Copyright © Pasi Laaksonen