Java Tutorial

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

public class textFieldDemo extends Applet
{
      String str;
      int a,b,result;
      TextField t1,t2;   //Creating Object of TextField Class
      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)
     {
          str=t1.getText();
          a=Integer.parseInt(str);
          str=t2.getText();
          b=Integer.parseInt(str);
          result=a+b;
          str=String.valuOf(result);
          g.drawString(\"Addition of both the field is :  \"+str,0,100);
     }
}

    Related Post:
  1. Program to show the use of Nested If-Else Statements

  2. Program to declare and initialize Boolean variables and print them on the Standard Output Device

  3. Program to show the use of For Loop

  4. Program to show the use of Conditional (Ternary) Operator

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

  6. File handling program to count number of characters in a file

  7. Program to show an example of extraction of characters from a StringBuffer objects

  8. An applet program to display Horizontal Color Bar

  9. Program to generate Fibonacci Series of a given number

  10. corba program of client and a DNS server where given a URL the server sends back an IP address

  11. Program to compare Strings by compring successive corresponding characters, starting with the first character in each String

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

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

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

  15. An application that combines several classes and interface

  16. Program of storing and retrieving integers using data streams on a single file

  17. An applet program to perform merge sort

  18. Program to convert the given temperature in faherenhiet to celsius using the following conversion formula C= F- 32/1.8

  19. Program to show the use of Bitwise Operator (~) Complement

  20. 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

 
 
Didn't find what you were looking for? Find more on An applet program to add two numbers where data is entered in TextField