Java Image Rotator Banner
November 19, 2007 | Barry Wise | Code Samples
Comment
Today a lot of people are doing this with Flash … back in the day I did it old school with Java.
/*
java_banner.java ver 1.1 (Final Release)
Barry Wise, 10/98
Version 1.1 Final Release 2/1/2000
This applet is freeware. For minimal support and customizations, please contact
the author at bwise@cybernex.net.
Source supported at: http://www.barrywise.com/
This Java applet is designed to work in all browsers which support Java, namely IE 3+ and Netscape 2+.
It cycles through a number of images (as many as you want). There are only a few parameters to set:
applet_speed: The number of milliseconds before the next banner image loads (Cannot be less than 500)
background_color: Set this to your page's background color in HEX format (i.e. FFFFFF = white).
border: Set to 0, nothing. Set this to 1 if you want a small black border around all the images.
number_of_links: The number of images and links you have specified.
pageLink0, pageLink1, etc.: The URL for each corresponding image (unlimited number of links available).
imageSrc0, imageSrc1, etc.: The Banner Image to correspond with each URL in pageLink, also unlimited.
*/
import java.applet.*;
import java.awt.*;
import java.net.*;
public class java_banner extends Applet implements Runnable {
int applet_speed, applet_width, applet_height, number_of_links, border;
int current = 0;
Color background_color;
URL link;
Image banner;
String[] banner_image;
String[] page_link;
Thread runner;
MediaTracker mt;
public void init() {
System.out.println("Java_Banner Applet developed 10/98 by Barry Wise, http://www2.cybernex.net/~bwise/");
// get parameter info
String speed = getParameter("applet_speed");
applet_speed = Integer.parseInt(speed);
if (applet_speed <= 500) { applet_speed = 500; } String bgcolor = getParameter("background_color"); background_color = new Color(Integer.valueOf(bgcolor, 16).intValue()); String int_border = getParameter("border"); border = Integer.parseInt(int_border); String links = getParameter("number_of_links"); number_of_links = Integer.parseInt(links); page_link = new String[number_of_links]; banner_image = new String[number_of_links]; // Main algorythm for getting links and image names. for (int i = 0; i < mt =" new" i =" 0;" banner =" getImage(getDocumentBase()," banner =" getImage(getDocumentBase()," border ="="" i="0;" link =" new" runner ="="" runner =" new" current ="="" current =" 0;"> 1) {
current++;
}
}
}
public void stop() {
if (runner != null) {
runner.stop();
runner=null;
}
}
} // End java_banner
Tags: banner, image rotator, itcn, java, programming
Similar Posts:
- Java Operating System Identifier
- Fnerd Java Menu Applet
- Marketing Your Online Presence: Banner Ads or Text Links
- Global Find and Replace In WordPress using MySQL
- SEO Search Engine Friendly URLs with ASP.NET and IIS
Comments
Leave a Reply






















