internet.com logo The Java Boutique
 ARTICLES
Tutorials
Reviews
Glossary
 APPLETS
by Category
by Date
by Name
Hall of Fame
Archive
Submit
Source Code
Servlets and JSP
 COMMUNITY
FAQ
Users Poll
Discussion Forum
Contact Us
 OTHER RESOURCES
Custom Applets
Java@Work
Java News
Jini Watch
Affiliate Programs

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

internet.commerce
Partner With Us














WebDeveloper Network
ExtremeFlash
FlashKit
FlashPlanet
Gif.com
JavaBoutique
JavaScript.com
JavaScriptSource
Jobs.Webdeveloper.com
JustSMIL
ScriptSearch
StreamingMediaWorld
VoiceXML Planet
WebDevelopersJournal The WDVL
WebDeveloper.com
WebReference.com
XML101

Web Developer
Opt-in Lists

CGI
HTML
Java
JavaScript
Web Design and Promotion
Web Site Development
E-mail Address:


Can you receive
HTML e-mail?

Yes   No

Zip Code:


TextFade


import java.applet.*;
import java.awt.*;
import java.util.*;

/* a utility class that collects parameters, converts hex color parameter values, and fonts */

class ParameterCollector
{
	public ParameterCollector(String counterToken, Applet a) {
		pCount = 1;
		while( a.getParameter(counterToken + pCount++) != null )
			;
		pCount = pCount-2;
		apl = a;
	}

	public int getCount() {
		return pCount;
	}

	public String[] get(String token) {
		String[] temp = new String[pCount];
		for (int i=0; i < pCount; i++)
			temp[i] = apl.getParameter(""+token + (i+1));
		return temp;
	}

	public Color[] hexConvert(String[] hexString)
	{
	   Color[] colorArray = new Color[pCount];

	   for (int i=0; i < hexString.length; i++) {
		   int a = getDec(hexString[i].substring(0, 1));
		   int b = getDec(hexString[i].substring(1, 2));
		   int c = getDec(hexString[i].substring(2, 3));
		   int d = getDec(hexString[i].substring(3, 4));
		   int e = getDec(hexString[i].substring(4, 5));
		   int f = getDec(hexString[i].substring(5, 6));

		   int x = (a * 16) + b;
		   int y = (c * 16) + d;
		   int z = (e * 16) + f;

		   Color col = new Color(x,y,z);
		   if (col != null)
				colorArray[i] = col;
		   else
				colorArray[i] = Color.white;
		}
		return colorArray;
	}

	public Color hexConvert(String hexString)
	{
		 Color[] colorArray = new Color[1];
		 String[] temp = new String[1];
		 temp[0] = hexString;

		 colorArray = hexConvert(temp);

		 return colorArray[0];
	}

	private int getDec(String hex)
	{
		int dValue;
		if(hex.equalsIgnoreCase("A"))		dValue = 10;
		else if(hex.equalsIgnoreCase("B"))	dValue = 11;
		else if(hex.equalsIgnoreCase("C"))	dValue = 12;
		else if(hex.equalsIgnoreCase("D"))	dValue = 13;
		else if(hex.equalsIgnoreCase("E"))	dValue = 14;
		else if(hex.equalsIgnoreCase("F"))	dValue = 15;
		else
			try {
				dValue = Integer.parseInt(hex);
			}
			catch (NumberFormatException e) {
				dValue = 0;
			}

		return dValue;
	}

	public int getFontStyle(String s)
	{
		if (s.equalsIgnoreCase("bold")) return Font.BOLD;
		else if (s.equalsIgnoreCase("italic")) return Font.ITALIC;
		else if (s.equalsIgnoreCase("bolditalic") || s.equalsIgnoreCase("bold italic")) return (Font.BOLD | Font.ITALIC);
		else return Font.PLAIN;
	}

	private Applet apl;
	private int pCount;
}

Return to TextFade



Applet Index
(sorted alphabetically)

A B C D E F G H I J K
L M N O P Q R S T U
V W X Y Z #s
The Java Source
(applets w/source code)

A B C D E F G H I J K
L M N O P Q R S T U
V W X Y Z

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.


Copyright 2002 INT Media Group, Incorporated. All Rights Reserved.
Legal Notices,  Licensing, Reprints, & Permissions,  Privacy Policy.
http://www.internet.com/