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. Program to show an example of creating a String object from a StringBuffer Object

  2. Program to show the use of Labeled Break Statement

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

  4. An applet program to draw different shapes

  5. Add,delete,Update in LISTS

  6. Program to show an example of Arrays of String

  7. program which takes a long sentence from the client passes to the server,server separates out each word and sends them back to client in reverse order

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

  9. Program of insertion sort

  10. Program that maintains employee database of an education system

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

  12. Program for calculating area of a circle on server side,when a client sends request along with given radius and then displaying result on client side

  13. Program to print some text on the same line using multiple print statements

  14. Program that reads and writes random access file

  15. Program to declare, initialize and print a StringBuffer object

  16. Program to display attributes of a specified file

  17. Program to show an example of using initialization block to initialize the data members of a class

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

  19. Program to show the use of operator (&lt;&lt;) Shift Left filling with zero from the right

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

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