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 give demo of getDocumentBase() and getCodeBase() methods

  2. Program to search an element in an array using Linear Search

  3. Program which calls the method sort(int []a) which throws the Exception ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

  4. Corba program of Count Client Applet, IDL,Server, Client

  5. Program to append a StringBuffer by StringBuffer, String objects and other Basic Data Types

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

  7. Program to show the use of Increment and Decrement Operators

  8. Create an interface coversions. Which have the following functions Inchestomillimeters(), hptowatts(),wattstohp(),poundstogram(),gramtopounds()

  9. An application that combines several classes and interface

  10. Program that accepts a shopping list of items from the command line and stores them in a vector. Also provide facility to perform operation

  11. Program to show an example of Driving and using a Class

  12. Program to show an example of Copying i.e. Clonning Objects

  13. Program of reading and writing primitive data

  14. Program to show the use of Nested Loops

  15. File handling program to display directory contents

  16. Program to ask question and accept answer up to 3 attempt and display right answer if it is wrong

  17. An applet program to add two numbers where data is entered in TextField

  18. Program to show an example of creating a class and using its object

  19. Program to show the comparing of Strings for equality

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

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