Ascii.java


/*Ascii.java
This applet will demonstrate how to output different characters
using the corresponing ascii value.

< applet
code=Ascii
width=200
height=275 >
< /applet >

*/

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

public class Ascii extends Applet
{
	short current=-1, first;
	TextField asc_fld=new TextField(5);
	TextArea result=new TextArea(8,25);

	public void init()
	{
		add(new Label("Initial ASCII value:"));
		add(asc_fld);
		add(new TextArea("See ASCII values one at a time\nby clicking the button below.", 2, 30));
		add(new Button("See next ASCII value."));
		add(result);
	}

	public boolean action(Event evt, Object obj)
	{
		int seed=Integer.parseInt(asc_fld.getText());
		if (seed==first)
			current++;
		else
		{
			result.setText("ASCII Value            Character\n-------------------------------\n");
			first=(short)seed;
			current=(short)seed;
		}
		result.appendText(""+current+"               "+(char)current+"\n");
		return true;
	}
}



Output for Ascii.java