/**
 *<APPLET
	code	= "../../index.htm"
	width	= "100"
	height	= "80"
	>
   </APPLET>
 **/
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class Conversor extends JApplet{
	JTextField txtEur = new JTextField("0");
	JTextField txtPts = new JTextField("0");
	
	static int aPesetas(double eur){
		return (int)(eur * 166.386);
		
	}
	
	static double aEuros(int pts){
		return ((int)(pts / 166.386 * 100 + 0.5)) /100.0;			
	}
	

	public void init(){
		Box b = Box.createVerticalBox();
		b.add(new JLabel("Euros:"));
		b.add(txtEur);
		b.add(new JLabel("Pesetas:"));
		b.add(txtPts);
		getContentPane().add(b);
		txtEur.addActionListener(new PulsarIntroListener());
		txtPts.addActionListener(new PulsarIntroListener());
	}
	
	class PulsarIntroListener implements ActionListener{
		public void actionPerformed(ActionEvent e){
			Object o = e.getSource();
			if(o == txtEur){
			   	txtPts.setText(String.valueOf(aPesetas(Double.parseDouble(txtEur.getText()))));
			}
			else			   
				txtEur.setText(String.valueOf(aEuros(Integer.parseInt(txtPts.getText()))));
		}
	}
					
}

		
