import java.awt.*;
import java.applet.*;


public class Applet1 extends Applet
{
	String elementos[]={"uno","dos","tres","cuatro", "cinco","seis","siete","ocho","nueve","diez"};
	Button boton[]=new Button[10];
	Panel centro=new Panel();
	Panel sur= new Panel();
	public int cont=0,i;
	
	public void init()
	{
		setBackground(Color.blue);
		setForeground(Color.yellow);
		for(i=0;i<elementos.length;i++)
		boton [i]=new Button (elementos[i]);
		setLayout(new BorderLayout());
		sur .add(new Button ("Agregar"));
		sur .add(new Button ("Eliminar"));
		sur .add(new Button ("Eliminar todos"));
		add("Center",centro);
		add("South",sur);
	}
	public boolean Action (Event e, Object o)
	{
		if(o.equals("Agregar"))
		{
			if (cont<10)
			{
				centro.add("Center",boton[cont++]);
				centro.validate();
			}
			return true;
		}
		if(o.equals("Eliminar"))
		{
			if (cont>0)
			{
				centro.remove(boton[--cont]);
				centro.validate();
			}
			return true;
		}
		if (o.equals("Eliminar todos"))
		{
			centro.removeAll();centro.validate();cont=0;return true;
		}
		
		return false;
	}
}

	