//	Copyright Naoki Hada
//	1996.4.26

     /*----------------------------------------------------/
    /   Naoki Hada  I wish just DokiDoki&WakuWaku.        /
   /   E-mail:HGG01341@niftyserve.or.jp                  /
  /   http://www.a-web.co.jp/~nhada/index.html          /
 /   daytime:(+1-415)813-9088 Pager:(+1-714)238-0930   /
/----------------------------------------------------*/

import	java.applet.Applet;
import	java.awt.*;
import	java.lang.Number;


//	for( showStatus( stings );




public	class	FlickerString	extends	Applet	implements Runnable{
	int		x;
	int		y;
	String	string;
	Color	color1;
	Color	color2;
	Color	currentColor;
	Thread	thread;

	public	void	init(){
		x = 0;
		y = 0;
		color1 = Color.red;
		color2 = Color.blue;
		string = "FlickerString by Naoki Hada";
		currentColor = color1;

		String	buf;
		if( null != ( buf = getParameter( "x" )))		x = Integer.parseInt( buf );
		if( null != ( buf = getParameter( "y" )))		y = Integer.parseInt( buf );
		if( null != ( buf = getParameter( "string" )))	string = buf;
//		if( null != ( buf = getParameter( "color1" ))){
//			String	RGB = buf;
//			String	colorRGB = "0x00" + RGB;
//			colorRGB = "0x00" + RGB;
//			color1 = Color( colorRGB );
//		}
//		if( null != ( buf = getParameter( "color2" ))){
//			String	RGB = buf;
//			String	colorRGB = "0x00" + RGB;
//			colorRGB = "0x00" + RGB;
//			color2 = Color( Integer( colorRGB ));
//		}
		setBackground( Color.black );
	}

	public	void	paint( Graphics g ){
//		showStatus( "x=" + x +" y=" + y + " string=" + string );

		g.setColor( currentColor );
		g.drawString( string, x, y );
		return;
	}

	public	void	start(){
		if( null == thread ){
			thread = new Thread( this );
			thread .start();
		}
	}

	public	void	stop(){
		if( null != thread ){
			thread.stop();
			thread = null;
		}
	}

	public	void	run(){
		while( true ){
			try{
				Thread.sleep(100);
			}catch( InterruptedException e ){
				break;
			}
			if( currentColor == color1 )	currentColor = color2;
			else							currentColor = color1;
			repaint();
		}
	}
}

