Java Tutorial

 
 
 
 
/* <applet code=\"sumOf2No\" height=150 width =350>
   </applet> */

import java.awt.*;
import java.applet.*;

public class sumOf2No extends Applet
{
     TextField T1,T2;

     public void init() {
         T1 = new TextField(10);
         T2 = new TextField(10);
         add(T1);
         add(T2);
         T1.setText(\"0\");
         T2.setText(\"0\");
      }

      public void paint(Graphics g) {
           int a, b, result;
           String str;

           g.drawString(\"Enter Number in TextField to Find addition of 2 No \",10,50);
           g.setColor(Color.red);
           str=T1.getText();
           a=Integer.parseInt(str);
           str=T2.getText();
           b=Integer.parseInt(str);
           result=a+b;
           g.drawString(\"After Addition the Result is : \"+result,10,80);
           showStatus(\"Addition of 2 Numbers\");
        }

        public boolean action(Event e, Object o){
            repaint();
            return true;
        }
}

    Related Post:
  1. An applet program to find maximum of three numbers using textField

  2. Program to show the use of Conditional AND Operator (&&) in If Statements

  3. Program to display following things on the client machine a)date and time of the server machine b)date and time of the client machine and difference

  4. Corba program to develop a simple calculator with addition, subtraction, multiplication and division capabilities, data collection from client side

  5. Pass the marks of 10 students from the client side design a servlet, which takes these marks and returns the number of students who obtained first cls

  6. Program to copy the elements of an array into another array in reverse order and print them

  7. CORBA based application for addition of two mathematical expressions of the form (ax + by) and displaying the result on client side

  8. Program to read the table elements into a two-dimensional array temperature

  9. Develop a game application in CORBA for which the player will guess a number between 1 to 100, which will be compared to the random number generated b

  10. Program to show an example of creating String objects from Character Arrays

  11. An applet program to display Horizontal Color Bar

  12. Program to delete mth element from an input string

  13. An applet program to give demo of getDocumentBase() and getCodeBase() methods

  14. Program which will read a string and rewrite it in the alphabetical order

  15. An applet program of linear sort

  16. Program to show the use of operator (&gt;&gt;) Shift Right, propagating the sign bit from the left

  17. Program to show the use of If-Else Statement

  18. Program to show an example of overloading constructors in a class to initialize its data members

  19. Game application in CORBA for which player will guess a number between 1 to 100, which will be compared to the random number generated by the class

  20. Program of creating a file using text fields in windows

 
 
Didn't find what you were looking for? Find more on An applet program to display sum of two number of textField