import java.applet.*;
import java.awt.*;

public class shoplist extends Applet

{
  List slist = new List(8,false);
  List thelist = new List(10,false);
  public void init()
	{
	  fillthelist();
	  add(thelist);
	  add(new Button(">>>>"));
	  add(slist);
	  add(new Button("Clear"));
	  add(new Label("Select an item from the list on the left and hit >>>> to place it in the other list"));
	}
public void fillthelist()
{
  thelist.addItem("Coffee");
  thelist.addItem("Bananas");
  thelist.addItem("Oranges");
  thelist.addItem("Pears");
  thelist.addItem("Peaches");
  thelist.addItem("Tuna");
  thelist.addItem("Bread");
  thelist.addItem("Milk");
  thelist.addItem("Eggs");
  thelist.addItem("Butter");
  thelist.addItem("Sugar");
  thelist.addItem("Cereal");
  thelist.addItem("Java Manual");
}
public boolean action(Event evt, Object whatAction)
	{
	    if(!(evt.target instanceof Button))
	    {
	      return false;
	    } 
	    String buttonLabel = (String) whatAction;
	    if (buttonLabel == ">>>>")
	      {
	        slist.addItem(thelist.getSelectedItem());
	        thelist.delItem(thelist.getSelectedIndex());
		return true;
	      }
	      else
		{
		  slist.clear();
		  thelist.clear();
		  fillthelist();
		  return true;
		}
	}
}
