import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Ejemplo07 extends Applet implements ActionListener{

	Label ibiFuente, ibiEstilo, ibiTamaņo;
	Choice choFuente, choEstilo, choTamaņo;
	Button btnAplicar;
	TextArea txtS;
	
	public void init(){

		setLayout(null);

		ibiFuente=new Label("Fuente");
		ibiFuente.setBounds(10,10,100,25);
		add(ibiFuente);

		choFuente=new Choice();
		choFuente.setBounds(10,35,100,25);
		choFuente.add("Serif");
		choFuente.add("SansSerif");
		choFuente.add("Monospaced");
		choFuente.add("Dialog");
		choFuente.add("DialogInput");
		add(choFuente);
		
		ibiEstilo=new Label("Estilo");
		ibiEstilo.setBounds(10,70,100,25);
		add(ibiEstilo);
		
		choEstilo=new Choice();
		choEstilo.setBounds(10,95,100,25);
		choEstilo.add("Normal");
		choEstilo.add("Negrita");
		choEstilo.add("Italic");
		choEstilo.add("Negrita Italic");
		add(choEstilo);

		ibiTamaņo=new Label("Tamaņo");
		ibiTamaņo.setBounds(10,135,100,25);
		add(ibiTamaņo);

		choTamaņo=new Choice();
		choTamaņo.setBounds(10,160,100,25);
		choTamaņo.add("10");
		choTamaņo.add("20");
		choTamaņo.add("30");
		choTamaņo.add("40");
		choTamaņo.add("50");
		choTamaņo.add("60");
		choTamaņo.add("70");
		choTamaņo.add("80");
		choTamaņo.add("90");
		choTamaņo.add("100");
		choTamaņo.add("110");
		choTamaņo.add("120");
		add(choTamaņo);

		btnAplicar=new Button("Aplicar");
		btnAplicar.setBounds(10,195,100,25);
		btnAplicar.addActionListener(this);
		add(btnAplicar);

		txtS=new TextArea();
		txtS.setBounds(130,20,300,200);
		txtS.setText("Hola");
		add(txtS);
	}

	public void actionPerformed(ActionEvent e){
		
		if(e.getSource().equals(btnAplicar))
		{
			String fuente=leeFuente();
			int estilo=leeEstilo();
			int tamaņo=leeTamaņo();
			
			Font miFuente=new Font(fuente,estilo,tamaņo);

			txtS.setFont(miFuente);		
		}
	}
	
	String leeFuente()

	{
		return choFuente.getSelectedItem();
	}
	
	int leeEstilo()

	{
		int estilo=choEstilo.getSelectedIndex();
		switch(estilo)
		{
			case'1':return Font.PLAIN;
			case'2':return Font.BOLD;
			case'3':return Font.ITALIC;
			case'4':return Font.BOLD+Font.ITALIC;
			default:return 0;
		}
	}
	
	int leeTamaņo()

	{
		return Integer.parseInt(choTamaņo.getSelectedItem());
	}
}
