APLET_1.java_



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

public class APLET_1 extends Applet
{
	Button BOTON_1= new Button("LETRERO");
	Button BOTON_2= new Button("CUADRO");
	String MENSAJE = "RAFA POR PRIMERA VEZ";
	boolean bandera = true;


	public void init()
	{
		setLayout(null);		// fija el contenedor
		//setBackground(Color.red);	// color del fondo
		//setForeground(Color.yellow);	// color de los trazos
		BOTON_1.setBounds(2, 2, 100, 20);	// posicionamiento del boton
		BOTON_1.addActionListener(new ManejaEvento());	// captura del evento
		add(BOTON_1);			// inserción del botón
		BOTON_2.setBounds(2, 30, 100, 20);	// posicionamiento del boton
		BOTON_2.addActionListener(new ManejaEvento());	// captura del evento
		add(BOTON_2);			// inserción del botón
	}

	public void paint(Graphics R)
	{
		String MAT[][] = {{"1", "2", "3"}, {"4", "5", "6"}, {"7", "8", "9"}};
		int x = 200, y = 200;
		
		if (bandera)
			R.drawString(MENSAJE, 100, 150);
		else
		{
			for (int r = 0; r < 3; r++)
			{
				x = 200;
				for (int c = 0; c < 3; c++)
				{
					R.draw3DRect(x, y, 50, 50, true);
					R.drawString(MAT[r][c], x+10, y+20);
					x += 50;
				}
				y += 50;
			}
		}
	}

	class ManejaEvento implements ActionListener
	{
		public void actionPerformed(ActionEvent e)
		{
			String BOTON = e.getActionCommand();
			
			if (BOTON.equals("LETRERO") )
			{
				MENSAJE = "BOTONAZO 1";
				bandera = true;
			}
			else
			{
				MENSAJE = "BOTONAZO 2";
				bandera = false;
			}
			repaint();
		}
	}
}