Tuesday, 15 November 2011

Biggest of 3 nos. Using Applet

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
  public class big extends Applet implements ActionListener
  {
        TextField t1,t2,t3,t4;
        Label Result;
        Button b1;
        public void init()
       {
           t1=new TextField(10);
          add(t1);
           
          t2=new TextField(10);
          add(t2);
       
        t3=new TextField(10);
        add(t3);

          b1=new Button("Result");
          add(b1);
             
          b1.addActionListener(this);

          t4=new TextField(10);
          add(t4);
     }
      public void actionPerformed(ActionEvent e)
         {
         if(e.getSource()==b1)
          {
           if((Integer.parseInt(t1.getText())>Integer.parseInt(t2.getText())) && (Integer.parseInt(t1.getText())>Integer.parseInt(t3.getText())))
         
        {
         t4.setText(String.valueOf(t1.getText()));
        }
   
        else if(Integer.parseInt(t2.getText())>Integer.parseInt(t3.getText()))
   
        {
        t4.setText(String.valueOf(t2.getText()));
        }

        else

        {
        t4.setText(String.valueOf(t3.getText()));
        }
              }
         }
  }
/*
<applet code=big.class
width=300
height=400>
</applet>
*/

No comments:

Post a Comment