import java.applet.*;
   import java.awt.*;
   import java.awt.event.*;
   public class tempConverterT extends Applet implements MouseListener, ActionListener
   {
      TextField fTemp = new TextField(4);
      TextField cTemp = new TextField(4);
      Label Instructions = new Label("Click to Reset     ");
      Label F = new Label("º F");
      Label C = new Label("º C");
      Font medFont = new Font("Helvetica",Font.PLAIN,15);
      Font tinyFont = new Font("Helvetica",Font.PLAIN,8);
   
      Panel top,middle,bottom;
      public void init()
      {
         setLayout(new GridLayout(3,1));
         top = new Panel();
         middle = new Panel();
         bottom = new Panel();
      
         add(top);
         top.setBackground(Color.white);
         top.setForeground(Color.black);
         add(middle);
         middle.setBackground(Color.white);
         middle.setForeground(Color.black);
         add(bottom);
         bottom.setBackground(Color.white);
         bottom.setForeground(Color.black);
      
         top.add(fTemp);
         fTemp.addActionListener(this);
         fTemp.setFont(medFont);        
         fTemp.addMouseListener(this);
      
         top.add(F);
         F.setFont(medFont);
      
         middle.add(cTemp);
         cTemp.setFont(medFont); 
         cTemp.addActionListener(this);
         cTemp.addMouseListener(this);
      
         middle.add(C);
         C.setFont(medFont);
         bottom.add(Instructions);
         setSize(160,100);
      }
      public void start()
      {
         fTemp.setText("");    
         cTemp.setText("");
      }
      public void mouseClicked(MouseEvent e)
      {
         start();
      }
      public void mouseReleased(MouseEvent e)
      {
      }
      public void mouseEntered(MouseEvent e)
      {
      }
      public void mouseExited(MouseEvent e)
      {
      }
      public void mousePressed(MouseEvent e)
      {
      }
      public void actionPerformed(ActionEvent e)
      {
         Object source = e.getSource();
         try{
            Double tempF = Double.valueOf(fTemp.getText());
            double c=((tempF.doubleValue()-32.0)*(5.0/9.0))*10;
            cTemp.setText("" + (double) Math.round(c)/10);
         }
            catch(NumberFormatException Error)
            {
            }
         Double tempC = Double.valueOf(cTemp.getText());
         double f = (9.0/5.0*tempC.doubleValue() + 32)*10;
         fTemp.setText("" + (double) Math.round(f)/10 );
      }
   }