import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Ejemplo06 extends Applet implements ActionListener{

	Choice choRojo, choVerde, choAzul;
	Button btnCombinar;
	TextField txtColor;
	Label ibiR, ibiG, ibiB;

	public void init(){

		setLayout(null);

		ibiR=new Label("R");
		ibiR.setBounds(5,10,25,25);
		add(ibiR);

		choRojo=new Choice();
		choRojo.setBounds(40,10,70,25);
		for(int i=0;i<256;i++)
			choRojo.add(""+i);
		add(choRojo);
		
		ibiG=new Label("G");
		ibiG.setBounds(5,45,25,25);
		add(ibiG);

		choVerde=new Choice();
		choVerde.setBounds(40,45,70,25);
		for(int i=0;i<256;i++)
			choVerde.add(""+i);
		add(choVerde);

		ibiB=new Label("B");
		ibiB.setBounds(5,80,25,25);
		add(ibiB);

		choAzul=new Choice();
		choAzul.setBounds(40,80,70,25);
		for(int i=0;i<256;i++)
			choAzul.add(""+i);
		add(choAzul);

		btnCombinar=new Button("Combinar");
		btnCombinar.setBounds(10,115,100,25);
		btnCombinar.addActionListener(this);
		add(btnCombinar);

		txtColor=new TextField();
		txtColor.setBounds(130,10,200,125);
		add(txtColor);
	}

	public void actionPerformed(ActionEvent e){
		
		if(e.getSource().equals(btnCombinar))
		{
			int r=choRojo.getSelectedIndex();
			int g=choVerde.getSelectedIndex();
			int b=choAzul.getSelectedIndex();

			txtColor.setBackground(new Color(r,g,b));		
		}
	}
}
