FileDocCategorySizeDatePackage
EventChoice.javaAPI DocExample1125Tue Nov 27 10:37:04 GMT 2001None

EventChoice.java

/*
 * @(#)EventChoice.java 1.0 01/11/23
 *
 * You can also create your own project template by making a new
 * folder in the directory ..\JCreator\Template\. Use the other
 * templates as examples.
 *
 */

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

public class EventChoice extends Applet implements ItemListener
{
	private Choice ch1, ch2;
	private String 
	   chChoice = "What Day were you born? what was the season?";
	public void init() 
	{
		ch1 = new Choice();
		ch2 = new Choice();
		ch1.add("Sunday");
		ch1.add("Monday");
		ch1.add("Tuesday");	
		ch1.add("Wednsday");
		ch1.add("Thursday");
		ch1.add("Friday");	
		ch1.add("Saturday");	
		ch1.addItemListener(this);
		add(ch1);
		ch2.add("Spring");	
		ch2.add("Summer");
		ch2.add("Autumn");	
		ch2.add("Winter");
		ch2.addItemListener(this);
		add(ch2);
	}
	public void paint(Graphics g) {
		g.drawString(chChoice, 50, 60 );
	}
	
	public void itemStateChanged(ItemEvent ie)
	{
	  if (ie.getSource()==ch1)
	  {
	  	chChoice = "It was " + ie.getItem().toString();
	  }
	  repaint();
	}
	 
}