internet.com logo The Java Boutique Java is a trademark of Sun Microsystems, Inc.
 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
International

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

internet.commerce
Partner With Us
PDA Phones & Cases
Server Racks
Auto Insurance Quote
Computer Deals
Online Education
Boat Donations
Business Liability
Web Design
Imprinted Gifts
Memory Upgrades
Online Shopping
Laptops
KVM over IP
Best Price

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:


StringGradient


Java Source:

// Written By Bavo Bruylandt
// Http://javadesign.web.com
// This source is for reference only.
// Do not modify it for distribution.
// Thanks ;)


import java.io.*;
import java.lang.*;
import java.awt.*;
import java.applet.*;

public class Gradient extends Applet{
		String text;
		int a=0;
		int pixely=10;
		int fontsize;
		Color kleur;
		Color bgkleur;
		boolean upsidedown = false;
		int blue;
		int green;
		int red;
		int bgblue;
		String cyclecolor;
		int bggreen;
		int bgred;
		int cyclespeed;
    FontMetrics fontmetrics;
    int fontwidth = 0;


			
	public void init() {
		cyclecolor = getParameter("cyclecolor");
		text = getParameter("Text");
		cyclespeed = Integer.parseInt(getParameter("cyclespeed"));
		fontsize = Integer.parseInt(getParameter("Fontsize"));
  	red = Integer.parseInt(getParameter("fontred"));
   	green = Integer.parseInt(getParameter("fontgreen"));
   	blue = Integer.parseInt(getParameter("fontblue"));
  	kleur = new Color(red,green,blue);
		bgred = Integer.parseInt(getParameter("bgred"));
   	bggreen = Integer.parseInt(getParameter("bggreen"));
  	bgblue = Integer.parseInt(getParameter("bgblue"));
  	bgkleur = new Color(bgred,bggreen,bgblue);
		if (getParameter("upsidedown").equals("true")) upsidedown = true;
	}
	
	public void paint(Graphics g) {
		Image [] line = new Image [fontsize+fontsize/2];
		Graphics [] lineGraph = new Graphics [fontsize+fontsize/2];
 		Font nl = new Font("Impact", Font.PLAIN, fontsize);
   	FontMetrics fontmetrics = getFontMetrics(nl);
   	fontwidth = fontmetrics.stringWidth(text);

		for (int w=0;w<fontsize+fontsize/2;w++) {
 			line[w] = createImage(fontwidth+30,1);
 			lineGraph[w] = line[w].getGraphics();
			if (cyclecolor.equals("red")) {
				red+=cyclespeed;
				if (red >255)red=0;
			}
			else if (cyclecolor.equals("green")) {
				green+=cyclespeed;
				if (green >255)green=0;
			}
			else if (cyclecolor.equals("blue")) {
				blue+=cyclespeed;
				if (blue >255)blue=0;
			}
			else if (cyclecolor.equals("all")) {
				blue+=cyclespeed;
				red+=cyclespeed;
				green+=cyclespeed;
				if (blue >255)blue=0;
				if (red >255)red=0;
				if (green >255)green=0;

			}
  		kleur = new Color(red,green,blue);
 			lineGraph[w].setColor(kleur);
 			setBackground(bgkleur);
 			lineGraph[w].setFont(nl);
		}
		
		if (upsidedown) {
			for (int w=0;w<fontsize+fontsize/2-1;w++) {
				lineGraph[w].drawString(text,20,a);
				g.drawImage(line[w],20,pixely+20,this);
				a+=1;
				pixely++;
			}
		}
		else {
			for (int w=0;w<fontsize+fontsize/2-1;w++) {
				lineGraph[w].drawString(text,20,a);
				g.drawImage(line[fontsize+fontsize/2-1-w],20,pixely-fontsize+20,this);
				a+=1;
				pixely++;
		}
	}
	a=0;
	pixely=10;
	}
}		
Back to GradientString

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/