
import java.awt.*;
import java.applet.*;
import java.awt.event.*;


// The item listener interface for receiving item events

public class ChoiceB extends Applet implements ItemListener
{
	private TextField text1;
	private TextField text2;
	private Choice button;
	private Font font;
	private Label label;
	private List list;
	
	
	//method called by the browser or applt viewer
	// when an applet is going to be executed
	
	public void init()
	{
		String s = "Choice to read from the choice";
		label = new Label(s);
		label.setAlignment(Label.CENTER);
		font = new Font("TimesRoman",font.BOLD,12);
		label.setFont(font);
		
		text1 = new TextField(25);
		text1.setEditable(false);
		text1.setFont(font);
		
		
		button = new Choice();
		//adds the specified item listener to receive iutem events from the choice menu 
		button.addItemListener(this);
		
		button.addItem("English");
		button.addItem("German");
		button.addItem("Spanish");
		button.addItem("Greek");
		button.addItem("Italian");
		
		text2 = new TextField(35);
		text2.setEditable(false);
		text2.setFont(font);
		
		list = new List(4,false);
		//adds the specified item listener to receive item events from the choice menu
		list.addItemListener(this);
		
		list.add("Book");
		list.add("Magazine");
		list.add("Newspaper");
		list.add("Brochure");
		
		// add TextAreas and button to the applet
		add(label);
		add(button);
		add(text1);
		add(text2);
		add(list);
	}
	
	//invoked when an item has been selected or deselected 	
	
	public void itemStateChanged(ItemEvent e)
	{
		// checks if the button is pressed
		if (e.getSource()==button)
		{
			text1.setText(button.getSelectedItem());
		}
		if(e.getSource()==list)
		{
			text2.setText(list.getSelectedItem());
		}
	}
				
}		