LICENSE
This license ("License") contains rights and restrictions associated with use of the accompanying software. Read the License carefully before utilizing the software. By using the software you agree to be bound by the terms and conditions of this license.
You should be careful to check that your unzipping program has named the files correctly. Some DOS programs will name according to the old 8.3 format, rename .class files "*.cla".
The code which produces the above is:
<applet code=lake name=lake1 width=250 height=250> <param name=image value="scenic.jpg"> <param name=href value="http://www.spigots.com/spigots.htm"> </applet> <form> <img src="sunset_button.jpg" onmouseup="lake1.setImageValue('sunset.jpg');"> <img src="city_button.jpg" onmouseup="lake1.setImageValue('city.jpg');"> <img src="scenic_button.jpg" onmouseup="lake1.setImageValue('scenic.jpg');"> <img src="clouds_button.jpg" onmouseup="lake1.setImageValue('clouds.jpg');"> <br> <input type=checkbox value="Rocking on" onClick="lake1.toggleRocking();">Rocking <br> <input type=checkbox value="Underwater on" onClick="lake1.toggleUnderwater();">Underwater </form> |
There is NOTHING to pay. The applet is completely free. However, if you make a donation ($5 - $10?) to Ty Hafan, Children's Hospice of Wales, which is a charitable appeal formed to build, equip and run a Children's Hospice in Wales to provide care for terminally ill children, you can consider your applet well-and-truly registered. Click here for details on how to make a donation. They now have an excellent new OnLine donation page. In just a few minutes you can change a few old, crinkly, dirty little bank notes into a nice warm glow...
To include lake in a web page, you should copy all class files into the same directory as the web page and then insert an <APPLET...> tag into the page, e.g.
<applet code="lake" width= height=> <param name="image" value="sunset.jpg"> <param name="href" value="http://www.demon.co.uk/davidg/spigots.htm"> </applet> |
Each of the "PARAM" tags passes a value to the applet. The examples shown here are the "image" parameter and the "href" parameter. In general the "PARAM" tag has the following format:
<PARAM name="[PARAMETER NAME]" value="[PARAMETER VALUE]"> |
Note that in Communicator 4.5 you will need to insert the tags in one at a time. Do this by choosing "Insert/HTML Tag..." from the menu for the <applet...> tag, then each of the <param...> tags and so on. For a full list of the parameters that can be passed to lake, see below.
The following parameters can be passed to the lake:
IMAGE
parameter JPG or GIF file that you want to reflect.
<applet code=lake width=250 height=250> <param name=image value="scenic.jpg"> </applet> |
OVERLAY
parameter The JPG or GIF file that you want to appear over the animated image. Quite frequently an overlay would be a GIF file, so that parts of it can be made transparent and allow the lake image to show through.
<applet code=lake width=250 height=250> <param name=image value="scenic.jpg"> <param name=overlay value="dglogo.gif"> </applet> |
HORIZON
parameter The HORIZON parameter allows you to have a visual horizon within the image. This is useful in situations where the image already has water and a horizon in it. In this example the original example is placed next to the lake version. Notice how the applet is exactly the same size as the original image. This is because it is animating part of the image, rather than reflecting it.
<img src="horizon.jpg" width=250 height=183 align=left> <applet code=lake width=250 height=183> <param name=image value="horizon.jpg"> <param name=horizon value="96"> </applet> |
HREF
parameter The URL to link to when the applet is clicked. By default this is http://www.spigots.com/spigots.htm .
<applet code=lake width=250 height=250> <param name=image value="scenic.jpg"> <param name=href value="http://www.javasoft.com"> </applet> |
TARGET
parameter This is the name of the frame you want any linked page to appear in.
<applet code=lake width=250 height=250> <param name=image value="scenic.jpg"> <param name=href value="http://www.microsoft.com"> <param name=target value="newframe"> </applet> |
UNDERWATER
parameter TRUE if the image is to appear reflected on the underside of the water.
<applet code=lake width=250 height=250> <param name=image value="scenic.jpg"> <param name=underwater value="true"> </applet> |
ROCKING
parameter Set to TRUE if you want the boat rocking.
If you set the "ROCKING" parameter to "TRUE" then you almost certainly need to reduce the height of the applet.
<applet code=lake width=250 height=220> <param name=image value="scenic.jpg"> <param name=rocking value="true"> </applet> |
You will need to set the height of the applet by trial and error. Start off with the height equal to about 1.8 * height of original image. The only exception to this rule is if you are using the "Horizon" parameter, in which case you should set the image to the size of the image being used.
If you can still see a gap appearing at the bottom of the applet as the waves move backwards and forwards, then you should reduce the height a little.
I'd suggest you put the lake.class file in the same directory as the page on which it will appear. If you want to move it elsewhere then use the "CODEBASE" option to point to the appropriate directory.
Some implementations of Java will not allow you to put the .class file in one subdirectory and the image file in another. If the try it might cause a security exception.
Well for a start, if you are not using at least version 4 of Netscape or Internet Explorer, it won't be reacting at all. So if clicking on the images and the checkbox are either having no effect or producing an error, that will probably be the reason.
The HTML source for the above is:
<applet code=lake name=lake1 width=250 height=250> <param name=image value="scenic.jpg"> <param name=href value="http://www.spigots.com/spigots.htm"> </applet> <form> <img src="sunset_button.jpg" onmouseup="lake1.setImageValue('sunset.jpg');"> <img src="city_button.jpg" onmouseup="lake1.setImageValue('city.jpg');"> <img src="scenic_button.jpg" onmouseup="lake1.setImageValue('scenic.jpg');"> <img src="clouds_button.jpg" onmouseup="lake1.setImageValue('clouds.jpg');"> <br> <input type=checkbox value="Rocking on" onClick="lake1.toggleRocking();">Rocking <br> <input type=checkbox value="Underwater on" onClick="lake1.toggleUnderwater();">Underwater </form> |
There are two important points to note in this code. Firstly, the <applet...> tag has been given a "name" attribute. Secondly, the different image and checkbox controls call methods as if the applet were a form or a text box on the web page. In fact the applet has become part of the browser's object model.
So - what are lake's methods?
setImageValue changes the image that is currently being reflected in the lake. The variable x should the name of a JPG or GIF file accessible by the applet.
setOverlayValue sets the filename of the overlay image.
setTargetValue sets the target frame of the applet's "href" parameter.
setHRefValue sets the hyperlink destination for when the applet is clicked.
setSpeedValue sets the animation speed (1 - 100).
setHorizonValue sets the level of the horizon (1 - height of image).
setRockingValue sets whether the applet is rocking or not. The value passed should be either "true" or "false".
toggleRocking sets the rocking on and off alternately.
setUnderwaterValue sets whether the image is viewed from underwater or not. The value passed should be either "true" or "false".
toggleUnderwater sets underwater viewing on and off alternately.
If the applet remains blank when it is run off the server and never shows the image, the chances are there are problems with the image. If the image is too large then it may not be able to create the animation in memory. On the other hand, it may be that the image is not accessible. Have you spelt the image filename correctly in the
<param name=image...> |
If you make the applet too large then you will notice a blank strip appear at the bottom of it as the waves lap backwards and forwards. The solution is to make the applet a bit smaller...
On an artistic note, it is not a good idea to use an image that already has a horizon. If you look across the surface of a lake you will not see the horizon reflected in the surface. The best solution is to cut the image *at* the horizon.
Do not use transparent GIFs with the applet's "image" parameter. There is no problem using transparent GIFs for the overlay parameter - in fact this is recommended. You can usually tell if a transparent GIF has been used because the top half of the applet will have parts which appear to be upside down.
Some web browsers have trouble opening applets straight from a hard disk. I have noticed this happen with Internet Explorer 3 and Netscape 4. Once you have loaded the class file and the web page onto your web site you should find it works OK.
Class files are binary files, just like image files are. Binary files contain more information than text (also known as ASCII) files do. If you transfer class files as if they were ASCII files then they will lose this extra information and will become corrupted. How do you transfer class files as binary files? You should transfer them in the same way that you transfer image files.
This is a very common problem. It may be because of one of the following:
Bruce's site is particularly recommended.
If you use this applet then it would be nice if you gave me a link by copying the image:
(this is the file "dglogo.gif" in the .zip archive) into the same directory as your web page and then pasting the following into your page.
<a href="http://www.spigots.com/spigots.htm" target="_top"> <img src="dglogo.gif" width=88 height=31 border=0></a> |
It will put a little button on your page that will link through to my Java Spigots page.
It is only a request: feel free to omit it.
If you still have trouble getting the applet to work and you have tried all of the possible solutions listed above, then feel to contact me, remembering to include:
These two pieces of information will make it a lot easier for me to solve the problem. I cannot guarantee that I will be able to respond to all messages (there's only so many hours in the day...) but sending the URL of a page that doesn't work will greatly increase the chances of getting an answer.
Remember to keep a look out at my web site for new applets.
17/05/2001